aboutsummaryrefslogtreecommitdiff
path: root/mem.py
diff options
context:
space:
mode:
authorpacien2018-03-17 20:38:29 +0100
committerpacien2018-03-17 20:38:29 +0100
commitff949b6802756f5a15cb528208e3cc71d7a7526c (patch)
treee1b65f3fa3e652562e34680852a5b957ec6cb19b /mem.py
downloadmempager-simulator-ff949b6802756f5a15cb528208e3cc71d7a7526c.tar.gz
Bootstrap project
Diffstat (limited to 'mem.py')
-rw-r--r--mem.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/mem.py b/mem.py
new file mode 100644
index 0000000..7137ede
--- /dev/null
+++ b/mem.py
@@ -0,0 +1,23 @@
1#!/usr/bin/env python3
2
3# UPEM / Programmation système / Projet : Simulation de gestion de mémoire virtuelle
4# Pacien TRAN-GIRARD et Adam NAILI
5
6
7class Memory:
8 def __init__(self, main_size, virt_size):
9 self.main = [None] * main_size
10 self.virt = [None] * virt_size
11
12 def _mem_to_string(self, mem):
13 return ''.join(['%d' % n if n is not None else 'x' for n in mem])
14
15 def dump_main(self):
16 return self._mem_to_string(self.main)
17
18 def dump_virt(self):
19 return self._mem_to_string(self.virt)
20
21 def has_page(self, page):
22 return 0 <= page < len(self.virt)
23