Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems Lecture 15.

Similar presentations


Presentation on theme: "Operating Systems Lecture 15."— Presentation transcript:

1 Operating Systems Lecture 15

2 © Copyright Virtual University of Pakistan
Agenda for Today Review of previous lecture Shortest-job-first Round-Robin scheduling Multi-level queues scheduling Multi-level feedback queues scheduling Recap of lecture 21 November 2018 © Copyright Virtual University of Pakistan

3 © Copyright Virtual University of Pakistan
Review of Lecture 14 Short-term scheduler Dispatcher Reasons for invoking scheduler Preemptive and non-preemptive schedulers Optimization criteria FCFS 21 November 2018 © Copyright Virtual University of Pakistan

4 Shortest-Job-First (SJF) Scheduling
Process with the shortest CPU burst is scheduled first. Non-preemptive – once CPU given to a process it cannot be preempted until completes its CPU burst. 21 November 2018 © Copyright Virtual University of Pakistan

5 Shortest-Job-First (SJF) Scheduling
Preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt it—Shortest-Remaining-Time-First (SRTF). SJF is optimal non-preemptive scheduling algorithm – gives minimum average waiting time for a given set of processes. 21 November 2018 © Copyright Virtual University of Pakistan

6 © Copyright Virtual University of Pakistan
Non-Preemptive SJF Process Arrival Time Burst Time P P P P Gantt chart Average waiting time = ( )/4 = 4 P1 P3 P2 7 16 P4 12 21 November 2018 © Copyright Virtual University of Pakistan

7 © Copyright Virtual University of Pakistan
Preemptive SJF Process Arrival Time Burst Time P P P P Gantt chart Average waiting time = ( )/4 = 3 P3 P2 4 2 11 P4 5 7 P1 16 21 November 2018 © Copyright Virtual University of Pakistan

8 SJF—CPU Burst of a Process
Can only estimate the length of the next CPU burst. Can be done by using the length of previous CPU bursts, using exponential averaging. 21 November 2018 © Copyright Virtual University of Pakistan

9 Exponential Averaging
Estimation based on historical data tn = Length of nth CPU burst n+1 = Estimate for n+1st CPU burst , 0 ≤  ≤1 n+1 = tn + (1- ) n 21 November 2018 © Copyright Virtual University of Pakistan

10 Exponential Averaging
Plugging in value for n, we get n+1 = tn + (1- )[tn-1 + (1- )n-1] = tn + (1- )tn-1 + (1- )2n-1 Continuing like this results in n+1 =  tn+ (1 - )  tn-1 + … + (1 - )j  tn-j + … + (1 - )n+1 0 21 November 2018 © Copyright Virtual University of Pakistan

11 Exponential Averaging
If  = 0 n+1 = n Actual previous bursts do not count If  = 1 n+1 = tn Estimates do not count 21 November 2018 © Copyright Virtual University of Pakistan

12 Exponential Averaging
Typical value used for  is ½. With this value, our n+1st estimate is Hence the name exponential averaging n+1 = tn/2 + tn-1/22 + tn-2/23 + tn-3/24 + … 21 November 2018 © Copyright Virtual University of Pakistan

13 © Copyright Virtual University of Pakistan
Priority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer  highest priority). Preemptive Non-preemptive 21 November 2018 © Copyright Virtual University of Pakistan

14 © Copyright Virtual University of Pakistan
Priority Scheduling SJF is a priority scheduling where priority is the predicted next CPU burst time. Problem  Starvation – low priority processes may never execute. Solution  Aging – as time progresses increase the priority of the process. 21 November 2018 © Copyright Virtual University of Pakistan

15 © Copyright Virtual University of Pakistan
Recap of Lecture Shortest-Job-First (SJF) Shortest-Remaining-Time-First (SRTF) Exponential averaging Priority scheduling Recap of lecture 21 November 2018 © Copyright Virtual University of Pakistan


Download ppt "Operating Systems Lecture 15."

Similar presentations


Ads by Google