From eea1484a9b9dd866fcc42314accac4ab15310ab8 Mon Sep 17 00:00:00 2001 From: Victor Pinheiro Date: Mon, 10 Jun 2019 10:41:26 -0300 Subject: [PATCH] =?UTF-8?q?=C3=9Altimo=20reparo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InterFace.py | 2 +- disk.py | 2 ++ mmu.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/InterFace.py b/InterFace.py index f064d53..a45318e 100644 --- a/InterFace.py +++ b/InterFace.py @@ -153,7 +153,7 @@ def run(self): for i in self.processes: i.io = io escalonator.insertProcess(i) - disk.putProcess(i.id, i.numpages) + disk.insertProcess(i.id, i.numpages) escalonator.not_arrived.sort(key=lambda x: x.start) escalonator.queue() diff --git a/disk.py b/disk.py index d77f540..0b2e2f9 100644 --- a/disk.py +++ b/disk.py @@ -18,6 +18,8 @@ def putProcess(self, id, qnt): self.memory[index].isAllocated = True count -= 1 + def insertProcess(self, id, qnt): + count = qnt for i in range(count): page = Page(id, allocated=True) self.memory.append(page) diff --git a/mmu.py b/mmu.py index c32bc86..c0bb86f 100644 --- a/mmu.py +++ b/mmu.py @@ -109,6 +109,7 @@ def allocatePage(self, process, ind, cpuProcess=None, hadSubstitution=False): free_list = list(filter(lambda page: not self.isAllocated(self.queue[page]), selec_list)) print(len(free_list)) print(free_list) + if len(free_list) > 0: rand = random.choice(free_list) @@ -230,7 +231,7 @@ def allocatePage(self, process, ref, cpuProcess=None): else: ram_ind, oldIndex = self.mem_ram.allocatePage(process, ref, cpuProcess=cpuProcess, hadSubstitution=False) - + if oldIndex != -1 and oldIndex != None: self.mem_vm[oldIndex] = [None, 0]