Skip to content

Commit

Permalink
Popravljen SPF
Browse files Browse the repository at this point in the history
  • Loading branch information
Veliki5382 committed Mar 29, 2024
1 parent a50c01f commit 0fa0bd1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
Binary file modified src/__pycache__/algorithmPlanner.cpython-310.pyc
Binary file not shown.
Binary file modified src/__pycache__/operatingSystem.cpython-310.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions src/algorithmPlanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def __init__(self):

def getProcess(self):
if not self.priorityQueue.empty():
return self.priorityQueue.get()
return self.priorityQueue.get()[1]
else:
return None

def putProcess(self, proc):
proc.size = field(compare=False)
self.priorityQueue.put(proc)
#proc.size = field(compare=False)
self.priorityQueue.put((-proc.size, proc))

def getNumberOfProcesses(self):
return self.priorityQueue.qsize()
Expand Down
1 change: 1 addition & 0 deletions src/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def run(self):

proc.remainingIterations -= 1
if proc.sleepInterval > 0: #ako je sleepInterval is 0, no need to sleep
print("Process [", proc.id, "] is sleeping.", sep='')
self.os.sleep(proc)
else:
self.os.finishProcess(proc)
2 changes: 1 addition & 1 deletion src/sanbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#os.createProcess(process3)s

print("--------------------------------")
os.cpuScheduler.setPrioritizedAlgorithm(fcfs)
os.cpuScheduler.setPrioritizedAlgorithm(spf)

process4 = Process(5, 50, 1)
os.createProcess(process4)
Expand Down

0 comments on commit 0fa0bd1

Please sign in to comment.