diff options
author | pacien | 2018-03-17 20:38:29 +0100 |
---|---|---|
committer | pacien | 2018-03-17 20:38:29 +0100 |
commit | ff949b6802756f5a15cb528208e3cc71d7a7526c (patch) | |
tree | e1b65f3fa3e652562e34680852a5b957ec6cb19b /mem.py | |
download | mempager-simulator-ff949b6802756f5a15cb528208e3cc71d7a7526c.tar.gz |
Bootstrap project
Diffstat (limited to 'mem.py')
-rw-r--r-- | mem.py | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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 | |||
7 | class 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 | |||