SRTF Shortest Remaining Time First - CPU Scheduling
SRTF Shortest Remaining Time First
CPU Scheduling
1. AIM
To simulate SRTF CPU Scheduling using structures and compute:
-
Completion Time
-
Turnaround Time
-
Waiting Time
-
Average Waiting Time
for a set of processes with given arrival and burst times.
2. THEORY
Shortest Remaining Time First (SRTF)
-
It is the preemptive version of SJF.
-
At every time unit, the scheduler picks the process with the shortest remaining time.
-
If a new process arrives with shorter remaining burst time → preemption happens.
-
Produces optimal waiting time but is difficult to implement.
3. ALGORITHM
-
Input n processes with arrival time and burst time.
-
Create structure array storing each process’s information.
-
At each time unit:
-
Select process with smallest remaining time that has arrived.
-
Decrement remaining time.
-
If remaining time = 0 → mark completion.
-
-
After all processes finish:
-
Compute Turnaround Time
-
Compute Waiting Time
-
-
Compute Average Waiting Time.
4. C PROGRAM – SRTF Using Structures
5. SAMPLE INPUT
6. SAMPLE OUTPUT
7. RESULT
The SRTF (Shortest Remaining Time First) scheduling algorithm was implemented using structures.
The program successfully computed:
-
Completion Time
-
Turnaround Time
-
Waiting Time
-
Average Waiting Time
for all processes based on preemptive shortest remaining time scheduling.
Comments
Post a Comment