lec9
lec9
● Associate with each process the length of its next CPU burst.
Use these lengths to schedule the process with the shortest
time.
● Two Schemes:
● Scheme 1: Non-preemptive
• Once CPU is given to the process it cannot be preempted until it
completes its CPU burst.
● Scheme 2: Preemptive
• If a new CPU process arrives with CPU burst length less than remaining
time of current executing process, preempt. Also called Shortest-
Remaining-Time-First (SRTF).
● SJF is optimal - gives minimum average waiting time for a given set of
processes.
1
24-01-2025
● Example
● Example
2
24-01-2025
Advantages-
Disadvantages-
•It can not be implemented practically since burst time of the processes can
not be known in advance.
•It leads to starvation for processes with larger burst time.
•Priorities can not be set for the processes.
•Processes with larger burst time have poor response time.
Problem-01:
Consider the set of 5 processes whose arrival time and burst time
are given below-
3
24-01-2025
Solution-
Problem-02: Consider the 5 processes whose arrival time and burst time
are given below-
If the CPU scheduling policy is SJF preemptive, calculate the average waiting
time and average turn around time.
4
24-01-2025
Solution-
Practice Problem 1
10
5
24-01-2025
Practice Problem 2
11
Practice Problem 3
12
6
24-01-2025
13