Skip to content

Instantly share code, notes, and snippets.

@adiparamartha
Created November 8, 2022 06:46
Show Gist options
  • Save adiparamartha/06bb0f3e7f3b57f47626f506e9f5a205 to your computer and use it in GitHub Desktop.
Save adiparamartha/06bb0f3e7f3b57f47626f506e9f5a205 to your computer and use it in GitHub Desktop.
SJF Scheduling Algorithm - Adi Paramartha - Python
#ShortestJobFirst Scheduling Algorithms
#Pseudocode: Execute task with shortest burst time / processing time first
import random
import time
i=1
a = random.randrange(1, 10)
b = random.randrange(1, 10)
c = random.randrange(1, 10)
d = random.randrange(1, 10)
e = random.randrange(1, 10)
taskList = {'Task_1': a , 'Task_2': b, 'Task_3': c, 'Task_4': d, 'Task_5': e}
for w in sorted(taskList, key=taskList.get, reverse=False):
print(w, " executed at ",i, " with load of ", taskList[w])
i+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment