Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.

Similar presentations


Presentation on theme: "Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other."— Presentation transcript:

1 Chapter 6 Scheduling

2 Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other program should execute if waiting for I/O

3 Preemptive Scheduling Takes place under the following conditions –I/O request or other request –interrupt –completion of I/O –termination Non-preemptive scheduling –scheduling takes place only on conditions 1 and 4 Preemptive scheduling –scheduling takes place on conditions 2 and/or 3

4 Preemptive Scheduling Can cause problems in critical sections –Either in user space –or in system space Disable interrupts for critical code sections

5 Dispatcher Module in OS that gives control of the CPU to the process selected by the short- term scheduler Involves –Switching context –Switching to user mode –jumping to the proper address to restart execution

6 Scheduling Criteria CPU utilization –should range from 40% to 90% Throughput –measured in processes per second Turnaround time –sum of periods spent from request to end waiting time –sum of the periods spent waiting in the ready queue response time – amount of time it takes to start responding –(not the time to output that response) –minimum variance

7 Scheduling Algorithms First-come first served Shortest-job-firstpriorityround-robin multilevel queue multilevel feedback queue

8 First-come first served Consider a set of processes that arrive in the given order. The CPU-burst time is given for each process. –p1: 24 ms –p2: 3 ms –p3: 3 ms P1P2P3 0 242730 Gantt chart

9 Shortest-Job-First Processes: –p1: 24 ms –p2: 3 ms –p3: 3 ms P1P2P3 0 3630 Gantt chart

10 Shortest-job first Provably optimal scheduling algorithm But… need to know the length of the next job. Can be estimated by computing the exponential average

11 Shortest job first Can be preemptive or non-preemptive –preemptive SJF is sometimes called shortest remaining time first scheduling What is Gantt chart for the following? –Process: arrival time: burst time –p1:0:8 –p2:1:4 –p3:2:9 –p4:3:5

12 Priority Scheduling Go from high priority to low priority Consider: –Process: arrival: time: priority –p1:0:10:3 –p2:1:1:1 –p3:2:2:4 –p4:4:1:5 –p5:6:5:2 What does Gantt chart look like? How do we prevent starvation?

13 Round-Robin Scheduling Designed especially for time-sharing systems. FCFS with preemption time quantum –amount of time a process will run before preemption –usually from 10-100 ms Circular ready queue Consider –time quantum of 4ms –Process:time –p1:24 –p2:3 –p3:3 What is average waiting time? What happens if time quantum is too small?

14 Round-Robin Scheduling Consider –P1: 6 –p2: 3 –P3: 1 –P4: 7 What happens to turn-around time as the time-quantum changes? Good rule of thumb: 80% of processes should be smaller than time-quantum

15 Multi-level Queue Scheduling Divides processes into different groups –background –foreground Each queue has its own scheduling algorithm (like round robin) Must also have a scheduling algorithm between queues –fixed-priority preemptive scheduling –time slice various queues

16 Multi-level Feedback Queue Scheduling Allows a process to move between queues purpose is to separate processes with different CPU-burst time characteristics High burst-time processes are moved into lower priority queues. Why? Algorithm –Processes are added to first queue. –if a process doesn’t complete in required time for that queue, it is placed at the tail of the next queue. –processes in higher queues preempt lower queues

17 Multiple-processor scheduling What kind of scheduling algorithm is best? –different queue per processor? –each processor examines one ready queue? –processors assigned to different tasks ex. I/O –others?? Which is better symmetric multi-processing or asymmetric multi-processing?

18 Real-time Scheduling Hard Real-time systems –must complete a critical task within a certain amount of time –Process is admitted along with an I/O time-estimate –Scheduler admits process or rejects it as impossible –Difficult or impossible if using secondary storage. why? Soft real-time systems –requires critical processes scheduled before less-critical processes –needs priorities. why? –needs small dispatch latency. why? –what about long kernel sections?

19 Real-time scheduling event response to event response interval process made available interrupt processing real-time process execution dispatch latency conflicts dispatch

20 Real-time scheduling Problem Priority inversion –higher priority processes waiting for lower priority processes to release resource solved by priority-inheritance protocol –lower-priority processes with a needed resource assume the priority of the requesting process

21 Algorithm Evaluation Select evaluation criteria –Ex. Maximize CPU utilization with the constraint that the max response time is 1 second maximize throughput such that turnaround time is linearly proportional to total execution time Select an evaluation method

22 Evaluation methods Deterministic Modeling –know specific process burst times –use Gantt chart Queuing Models –use mathematical equations –If we know any two of the following, we can compute the other. average arrival rate number of processes in queue expected waiting time per process Simulations –full simulation of processor system –random distribution of process wait time and arrival time Little’s Formula

23 Solaris 2 priority-based process scheduling –4 classes of scheduling real-timesystem time sharing interactive –Scheduling policy dynamically alters scheduling priorities using a multi-level feedback approach

24 Windows 2000 Priority-based preemptive scheduling algorithm 32-level priority scheme –Two classes of priorities variable: 1-15 real-time class : 16-32 –Several priority classes REALTIME_PRIORITY_CLASSHIGH_PRIORITY_CLASS…IDLE_PRIORITY_CLASS –Within each priority class there is a relative priority Time_CriticalHighest…LowestIdle

25 Windows 2000 When thread’s time quantum runs out –thread is interrupted –priority is lowered (1-15) –never lowered below base priority Distinguishes between –foreground processes increase time quanta by x3 –background processes

26 Linux Two separate process-scheduling algorithms –time sharing algorithm for fair preemptive scheduling –real-time tasks Linux uses a prioritized credit-based algorithm –process starts with a number of scheduling credits –process with most credits is run next –each time a timer interrupt occurs the running process loses one credit –when running processes credit reaches 0, another process is started –If no runnable processes have credits add credits to every process in the system credits = credits/2 + priority Processes that spend much of their time suspended accumulate credits Real-time scheduling –FCFS –RR


Download ppt "Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other."

Similar presentations


Ads by Google