Skip to content

Commit 8d459ed

Browse files
ADDED SCHEDULING ALGO
1 parent c989db7 commit 8d459ed

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

scheduling/preemptive_sjf(srtf).py renamed to scheduling/preemptive_sjf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""
2-
Shortest Remaining Time First (SRTF) scheduling is a preemptive version of Shortest Job First (SJF).
3-
At every unit of time, it selects the process with the smallest remaining burst time
4-
among the processes that have arrived.
2+
Shortest Remaining Time First (SRTF) scheduling is a preemptive version of
3+
Shortest Job First (SJF).
4+
At every unit of time, it selects the process with the smallest remaining
5+
burst time among the processes that have arrived.
56
https://en.wikipedia.org/wiki/Shortest_job_next#Preemptive_SJF_(SRTF)
67
"""
78

8-
from statistics import mean
9-
from typing import List
9+
def mean(a):
10+
return sum(a) / len(a)
1011

11-
def calculate_srtf_waiting_time(arrival: List[int], burst: List[int]) -> List[int]:
12+
def calculate_srtf_waiting_time(arrival: list[int], burst: list[int]) -> list[int]:
1213
"""
1314
Calculate waiting time for each process using Shortest Remaining Time First (SRTF).
1415

@@ -55,7 +56,7 @@ def calculate_srtf_waiting_time(arrival: List[int], burst: List[int]) -> List[in
5556

5657
return waiting
5758

58-
def calculate_srtf_turnaround_time(arrival: List[int], burst: List[int], waiting: List[int]) -> List[int]:
59+
def calculate_srtf_turnaround_time(arrival: list[int], burst: list[int], waiting: list[int]) -> list[int]:
5960
"""
6061
Calculate turnaround time for each process using waiting time.
6162

scheduling/priority_scheduling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
https://en.wikipedia.org/wiki/Priority_scheduling
66
"""
77

8-
from statistics import mean
8+
def mean(a):
9+
return sum(a) / len(a)
910

1011
def calculate_priority_waiting_time(arrival: list, burst: list, priority: list) -> list:
1112
"""

0 commit comments

Comments
 (0)