Explain Shortest-Job-First (SJR) Scheduling And Types With Example, Preemptive And Non Preemptive Scheduling Explain With Examples
In This Topic & Blog Having Any Query Then Post your Comment and Suggestion Below
Shortest-Job-First (SJR) Scheduling
• Associate with each process the length of its next CPU burst. Use these
lengths to schedule the process with the shortest time.
• Two schemes:
– Non preemptive Scheduling – once CPU given to the process it cannot be
preempted until completes its CPU burst.
– Preemptive Scheduling – if a new process arrives with CPU burst length less than
remaining time of current executing process, preempt. This scheme is
know as the Shortest-Remaining-Time-First (SRTF).
• SJF is optimal – gives minimum average waiting time for a given set of
processes.
Example of Non-Preemptive SJF
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (non-preemptive)
• Average waiting time = (0 + 6 + 3 + 7)/4 - 4
Example of Preemptive SJF
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (preemptive)
• Average waiting time = (9 + 1 + 0 +2)/4 - 3
Shortest Job First (SJF) Scheduling With Advantage :
• Having the least average waiting time, average
turn around time, average response time.
• Drawback:
• Knowing the length of the next CPU burst time, it
is difficult.
• It is optimal algorithm, it cannot be implemented
at the level of short – term CPU scheduling.
• “Aging” is the another problem, Big jobs are
waiting so much time for CPU.
Labels: Operating System