The document discusses the Shortest Job First (SJF) scheduling algorithm. SJF is a non-preemptive algorithm that selects the waiting process with the shortest execution time to execute next. It has the advantage of minimum average waiting time but may cause starvation if shorter processes keep arriving. SJF can be used in environments where accurate estimates of running times are available. The algorithm involves sorting processes by burst time and then applying First Come First Serve scheduling.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
186 views
Program For Shortest Job First
The document discusses the Shortest Job First (SJF) scheduling algorithm. SJF is a non-preemptive algorithm that selects the waiting process with the shortest execution time to execute next. It has the advantage of minimum average waiting time but may cause starvation if shorter processes keep arriving. SJF can be used in environments where accurate estimates of running times are available. The algorithm involves sorting processes by burst time and then applying First Come First Serve scheduling.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Program for Shortest Job First (or SJF)
scheduling | Set 1 (Non- preemptive)
1.8 Shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next. SJN is a non- preemptive algorithm. Shortest Job first has the advantage of having minimum average waiting time among all scheduling algorithms. It is a Greedy Algorithm. It may cause starvation if shorter processes keep coming. This problem can be solved using the concept of aging. It is practically infeasible as Operating System may not know burst time and therefore may not sort them. While it is not possible to predict execution time, several methods can be used to estimate the execution time for a job, such as a weighted average of previous execution times. SJF can be used in specialized environments where accurate estimates of running time are available. Algorithm: 1- Sort all the processes in increasing order
state.edu/~agrawal/660/Slides/jan18.pdf How to compute below times in Round Robin using a program? 1. Completion Time: Time at which process completes its execution. 2. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time 3. Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time – Burst Time Round Robin is a CPU scheduling algorithm where each process is assigned a fixed time slot in a cyclic way. It is simple, easy to implement, and starvation-free as all processes get fair share of CPU. One of the most commonly used technique in CPU scheduling as a core. It is preemptive as processes are assigned CPU only for a fixed slice of time at most. The disadvantage of it is more overhead of context switching. Illustration:
state.edu/~agrawal/660/Slides/jan18.pdf How to compute below times in Round Robin using a program? 1. Completion Time: Time at which process completes its execution. 2. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time 3. Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time – Burst Time