Skip to content

Commit

Permalink
Último reparo
Browse files Browse the repository at this point in the history
  • Loading branch information
vpinheiro38 committed Jun 10, 2019
1 parent 0ea7545 commit eea1484
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion InterFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit eea1484

Please sign in to comment.