Shortest Job First SJF Algorithm PRESENTATION
Shortest Job First SJF Algorithm PRESENTATION
First (SJF)
Algorithm
GROUP MEMBERS
EMAN SHABBIR (4394-FBAS/BSCS/F 21 A)
1 Step 1
2 Step 2
If the new process has a shorter burst time, the currently
running process is preempted (interrupted) and the new
process is executed.
3 Step 3
P1 0 ms 7 ms P1 (2 ms)
P2 2 ms 4 ms P2 (4 ms)
P3 4 ms 1 ms P3 (5 ms)
P4 5 ms 4 ms P2 (7 ms)
P4 (11 ms)
P1 (16 ms)
now, average waiting time = (completion time- burst time- arrival time)/total no. of processes
Step 1 Step 3
1 2 3
Step 2
If the new process has a
shorter burst time, it is added
to the ready queue but will not
interrupt the currently running
Example of Non-Preemptive SJF
Process Arrival Time Burst Time Execution Order
P1 0 ms 9 ms P1 (9 ms)
P2 3 ms 7 ms P3 (10 ms)
P3 5 ms 1 ms P2 (17 ms)
P4 6 ms 7 ms P4 (24 ms)
now, average waiting time = (completion time- burst time- arrival time)/total no. of processes
Advantages Disadvantages
Simpler to implement, less Increased average waiting time,
overhead, and better for CPU- potential for starvation of longer
bound processes. jobs, and less responsive to
changing system conditions.
Conclusion and Comparison of
Preemptive and Non-Preemptive
SJF
Preemptive SJF Non-Preemptive SJF
Optimizes CPU utilization, reduces average Simpler to implement and better for CPU-
waiting time, and prevents starvation. bound processes.
More complex to implement and may Increased average waiting time and
introduce additional overhead. potential for starvation of longer jobs.
PROJECT
OUTPUT
THANK YOU