From ff949b6802756f5a15cb528208e3cc71d7a7526c Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 17 Mar 2018 20:38:29 +0100 Subject: Bootstrap project --- mem.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mem.py (limited to 'mem.py') diff --git a/mem.py b/mem.py new file mode 100644 index 0000000..7137ede --- /dev/null +++ b/mem.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# UPEM / Programmation système / Projet : Simulation de gestion de mémoire virtuelle +# Pacien TRAN-GIRARD et Adam NAILI + + +class Memory: + def __init__(self, main_size, virt_size): + self.main = [None] * main_size + self.virt = [None] * virt_size + + def _mem_to_string(self, mem): + return ''.join(['%d' % n if n is not None else 'x' for n in mem]) + + def dump_main(self): + return self._mem_to_string(self.main) + + def dump_virt(self): + return self._mem_to_string(self.virt) + + def has_page(self, page): + return 0 <= page < len(self.virt) + -- cgit v1.2.3