Presentation is loading. Please wait.

Presentation is loading. Please wait.

COT 4600 Operating Systems Fall 2009

Similar presentations


Presentation on theme: "COT 4600 Operating Systems Fall 2009"— Presentation transcript:

1 COT 4600 Operating Systems Fall 2009
Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 3:00-4:00 PM

2 Lecture 29 – Tuesday November 30, 2010
Final exam – T December 9 4-6:50 PM Last time: Stack replacement algorithms The clock algorithm Today: Priority inversion Multi-level queue scheduling Comparison of scheduling algorithms Queuing Next Time: Review of the class. Lecture 29

3 Priority scheduling Each thread/process has a priority and the one with the highest priority (smallest integer  highest priority) is scheduled next. Preemptive Non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time Problem  Starvation – low priority threads/processes may never execute Solution to starvation  Aging – as time progresses increase the priority of the thread/process Priority my be computed dynamically Lecture 29

4 Priority inversion A lower priority thread/process prevents a higher priority one from running. T3 has the highest priority, T1 has the lowest priority; T1 and T3 share a lock. T1 acquires the lock, then it is suspended when T3 starts. Eventually T3 requests the lock and it is suspended waiting for T1 to release the lock. T2 has higher priority than T1 and runs; neither T3 nor T1 can run; T1 due to its low priority, T3 because it needs the lock help by T1. Allow a low priority thread holding a lock to run with the higher priority of the thread which requests the lock Lecture 29

5 Estimating the length of next CPU burst
Done using the length of previous CPU bursts, using exponential averaging Lecture 29 5

6 Exponential averaging
 =0 n+1 = n Recent history does not count  =1 n+1 =  tn Only the actual last CPU burst counts If we expand the formula, we get: n+1 =  tn+(1 - ) tn -1 + … +(1 -  )j  tn -j + … +(1 -  )n +1 0 Since both  and (1 - ) are less than or equal to 1, each successive term has less weight than its predecessor Lecture 29 6

7 Predicting the length of the next CPU burst
Lecture 29 7

8 Multilevel queue Ready queue is partitioned into separate queues each with its own scheduling algorithm : foreground (interactive)  RR background (batch)  FCFS Scheduling between the queues Fixed priority scheduling - (i.e., serve all from foreground then from background). Possibility of starvation. Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR 20% to background in FCFS Lecture 29 8

9 Multilevel Queue Scheduling
Lecture 29 9

10 Multilevel feedback queue
A process can move between the various queues; aging can be implemented this way Multilevel-feedback-queue scheduler characterized by: number of queues scheduling algorithms for each queue strategy when to upgrade/demote a process strategy to decide the queue a process will enter when it needs service Lecture 29 10

11 Example of a multilevel feedback queue exam
Three queues: Q0 – RR with time quantum 8 milliseconds Q1 – RR time quantum 16 milliseconds Q2 – FCFS Scheduling A new job enters queue Q0 which is served FCFS. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q1. At Q1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q2. Lecture 29 11

12 Multilevel Feedback Queues
Lecture 29 12

13 Unix scheduler The higher the number quantifying the priority the lower the actual process priority. Priority = (recent CPU usage)/2 + base Recent CPU usage  how often the process has used the CPU since the last time priorities were calculated. Does this strategy raises or lowers the priority of a CPU-bound processes? Example: base = 60 Recent CPU usage: P1 =40, P2 =18, P3 = 10 Lecture 29 13

14 Comparison of scheduling algorithms
Round Robin FIFO MFQ Multi-Level Feedback Queue SFJ Shortest Job First SRJN Shortest Remaining Job Next Throughput Response time May be low is quantum is too small Shortest average response time if quantum chosen correctly Not emphasized May be poor Good for I/O bound but poor for CPU-bound processes High Good for short processes But maybe poor for longer processes Lecture 29 14

15 Shortest Remaining Job Next
Round Robin FIFO MFQ Multi-Level Feedback Queue SFJ Shortest Job First SRJN Shortest Remaining Job Next IO-bound Infinite postponement No distinction between CPU-bound and Does not occur Gets a high priority if CPU-bound processes are present May occur for CPU bound processes May occur for processes with long estimated running times Lecture 29 15

16 Shortest Remaining Job Next
Round Robin FIFO MFQ Multi-Level Feedback Queue SFJ Shortest Job First SRJN Shortest Remaining Job Next Overhead CPU-bound Low No distinction between CPU-bound and IO-bound The lowest Can be high Complex data structures and processing routines Gets a low priority if IO-bound processes are present Can be high Routine to find to find the shortest job for each reschedule Can be high Routine to find to find the minimum remaining time for each reschedule Lecture 29 16


Download ppt "COT 4600 Operating Systems Fall 2009"

Similar presentations


Ads by Google