Download presentation
Presentation is loading. Please wait.
1
Scheduling
2
Review: Process Manager
Program Process Abstract Computing Environment Process Description File Manager Process Mgr Protection Deadlock Synchronization Device Manager Memory Manager Resource Manager Scheduler Devices Memory CPU Other H/W
3
Scheduling Scheduling mechanism is the part of the process manager that handles the removal of the running process of CPU and the selection of another process on the basis of a particular strategy Scheduler chooses one from the ready threads to use the CPU when it is available Scheduling policy determines when it is time for a thread to be removed from the CPU and which ready thread should be allocated the CPU next
4
Thread Scheduler Organization
Ready List Scheduler CPU Resource Manager Resources Preemption or voluntary yield Allocate Request Done New Thread job “Ready” “Running” “Blocked”
5
Thread Scheduling New threads put into ready state and added to ready list Running thread may cease using CPU for any of four reasons Thread has completed its execution Thread requests a resource, but can’t get it Thread voluntarily releases CPU Thread is preempted by scheduler and involuntarily releases CPU Scheduling policy determines which thread gets the CPU and when a thread is preempted
6
The Scheduler Organization
Ready Process Enqueuer Ready List Dispatcher Context Switcher Process Descriptor CPU From Other States Running Process
7
Enqueuer Adds processes which are ready to run to the ready list
May compute the priority for the waiting process (could also be determined by the dispatcher)
8
Context Switcher Saves contents of processor registers for a process being taken off the CPU If hardware has more than one set of processor registers, OS may just switch between sets Typically, one set is used for supervisor mode, others for applications Depending on OS, process could be switched out voluntarily or involuntarily
9
Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves: switching context From process, to dispatcher, to new process switching to user mode jumping to the proper location in the user program to restart that program
10
Process/Thread Context
Rn . . . Status Registers Functional Unit Left Operand Right Operand Result ALU PC IR Ctl Unit
11
Context Switching Old Thread Descriptor CPU New Thread Descriptor
12
Context Switch Timing Context switching is a time-consuming process
Assuming n general registers and m status registers, each requiring b store operations, and K time units to perform a store, the time required is (n + m) b × K time units Then a processor requiring 50 ns to store 1 unit of information, and assuming that n = 32 and m = 8, the time required is 2000 ns = 2 μs A complete context switch involves removing process, loading dispatcher, removing dispatcher, loader new process at least 8 μs required Note that a 1 Ghz processor could have executed about 4,000 instructions in this time Some processors use several sets of registers to reduce this switching time (one set for supervisor mode, the other for user)
13
Invoking the Scheduler
Need a mechanism to call the scheduler Voluntary call Process blocks itself Calls the scheduler Non-preemptive scheduling Involuntary call External force (interrupt) blocks the process Preemptive scheduling
14
Voluntary CPU Sharing Each process will voluntarily share the CPU
By calling the scheduler periodically The simplest approach Requires a yield instruction to allow the running process to release CPU yield(pi.pc, pj.pc) { memory[pi.pc] = PC; PC = memory[pj.pc]; }
15
Voluntary CPU Sharing – cont.
pi can be “automatically” determined from the processor status registers So function can be written as yield(*, pj.pc) { memory[pi.pc] = PC; PC = memory[pj.pc]; }
16
More on Yield pi and pj can resume one another’s execution
yield(*, pj.pc); . . . yield(*, pi.pc); Suppose pj is the scheduler: // p_i yields to scheduler yield(*, pj.pc); // scheduler chooses pk yield(*, pk.pc); // pk yields to scheduler // scheduler chooses ...
17
Voluntary CPU Sharing – cont.
Every process periodically yields to the scheduler Relies on correct process behavior Malicious Accidental Need a mechanism to override running process
18
Voluntary CPU Sharing – cont.
19
Involuntary CPU Sharing
Periodic involuntary interruption Through an interrupt from an interval timer device Which generates an interrupt whenever the timer expires The scheduler will be called in the interrupt handler A scheduler that uses involuntary CPU sharing is called a preemptive scheduler
20
Programmable Interval Timer
InterruptCount--; if (InterruptCount <= 0) { InterruptRequest = TRUE; InterruptCount = K } SetInterval( <programmableValue>) { K = <programmableValue>; InterruptCount = K; Interrupt occurs every K clock ticks
21
Involuntary CPU Sharing – cont
Interval timer device handler Keeps an in-memory clock up-to-date Invokes the scheduler IntervalTimerHandler() { Time++; // update the clock TimeToSchedule--; if(TimeToSchedule <= 0) { <invoke scheduler>; TimeToSchedule = TimeSlice; }
22
Contemporary Scheduling
Involuntary CPU sharing – timer interrupts Time quantum determined by interval timer – usually fixed size for every process using the system Sometimes called the time slice length
23
Choosing a Process To Run
Mechanism never changes Strategy = policy the dispatcher uses to select a process from the ready list Different policies for different requirements
24
Policy Considerations
Policy can control/influence: CPU utilization Average time a process waits for service Average amount of time to complete a job Could strive for any of: Equitability Favor very short or long jobs Meet priority requirements Meet deadlines
25
Optimal Scheduling Suppose the scheduler knows each process pi’s service time, t(pi) -- or it can estimate each t(pi) : Policy can optimize on any criteria, e.g., CPU utilization Waiting time Deadline To find an optimal schedule: Have a finite, fixed # of pi Know t(pi) for each pi Enumerate all schedules, then choose the best
26
However ... The t(pi) are almost certainly just estimates
General algorithm to choose optimal schedule is O(n2) Other processes may arrive while these processes are being serviced Usually, optimal schedule is only a theoretical benchmark – scheduling policies try to approximate an optimal schedule
27
Strategy Selection The scheduling criteria will depend in part on the goals of the OS and on priorities of processes, fairness, overall resource utilization, throughput, turnaround time, response time, and deadlines
28
Process Model and Metrics
P will be a set of processes, p0, p1, ..., pn-1 S(pi) is the state of pi {running, ready, blocked} τ(pi), the service time The amount of time pi needs to be in the running state before it is completed W (pi), the waiting time The time pi spends in the ready state before its first transition to the running state TTRnd(pi), turnaround time The amount of time between the moment pi first enters the ready state and the moment the process exits the running state for the last time
29
Simplified Model Simplified, but still provides analysis results
Ready List Scheduler CPU Resource Manager Resources Allocate Request Done New Process job “Ready” “Running” “Blocked” Preemption or voluntary yield Simplified, but still provides analysis results Easy to analyze performance No issue of voluntary/involuntary sharing
30
Estimating CPU Utilization
New Process Ready List Scheduler CPU Done Let l = the average rate at which processes are placed in the Ready List, arrival rate Let μ = the average service rate 1/ μ = the average t(pi) l pi per second System Each pi uses 1/ μ units of the CPU
31
Estimating CPU Utilization
New Process Ready List Scheduler CPU Done Let l = the average rate at which processes are placed in the Ready List, arrival rate Let μ = the average service rate 1/ μ = the average t(pi) Let r = the fraction of the time that the CPU is expected to be busy r = # pi that arrive per unit time * avg time each spends on CPU r = l * 1/ μ = l/ μ Note: must have l < m (i.e., r < 1) What if r approaches 1?
32
Optimization Criteria
Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time Which one to use depends on the system’s design goal
33
Nonpreemptive Schedulers
Blocked or preempted processes New Process Ready List Scheduler CPU Done Try to use the simplified scheduling model Only consider running and ready states Ignores time in blocked state: New process created when it enters ready state Process is destroyed when it enters blocked state Really just looking at “small phases” of a process
34
Everyday scheduling methods
First-come, first served (FCFS) Shorter jobs first (SJF) or Shortest job next (SJN) Higher priority jobs first Job with the closest deadline first
35
FCFS at the supermarket
36
SJF at the supermarket
37
Gantt Chart Used to illustrate deterministic schedules
Dependencies of a process on other processes Plots processor(s) against time Shows which processes on executing on which processors at which times Also shows idle time, so illustrates the utilization of each processor In following, will only assume one processor
38
First-Come-First-Served
Assigns priority to processes in the order in which they request the processor i τ(pi) 350 1 125 2 475 3 250 4 75
39
First-Come-First-Served – cont.
i t(pi) p0 TTRnd(p0) = t(p0) = 350 W(p0) = 0 350
40
First-Come-First-Served – cont.
i t(pi) 350 475 p0 p1 TTRnd(p0) = t(p0) = 350 TTRnd(p1) = (t(p1) +TTRnd(p0)) = = 475 W(p0) = 0 W(p1) = TTRnd(p0) = 350
41
First-Come-First-Served – cont.
i t(pi) 475 950 p0 p1 p2 TTRnd(p0) = t(p0) = 350 TTRnd(p1) = (t(p1) +TTRnd(p0)) = = 475 TTRnd(p2) = (t(p2) +TTRnd(p1)) = = 950 W(p0) = 0 W(p1) = TTRnd(p0) = 350 W(p2) = TTRnd(p1) = 475
42
First-Come-First-Served – cont.
i t(pi) 950 1200 p0 p1 p2 p3 TTRnd(p0) = t(p0) = 350 TTRnd(p1) = (t(p1) +TTRnd(p0)) = = 475 TTRnd(p2) = (t(p2) +TTRnd(p1)) = = 950 TTRnd(p3) = (t(p3) +TTRnd(p2)) = = 1200 W(p0) = 0 W(p1) = TTRnd(p0) = 350 W(p2) = TTRnd(p1) = 475 W(p3) = TTRnd(p2) = 950
43
First-Come-First-Served – cont.
i t(pi) 1200 1275 p0 p1 p2 p3 p4 TTRnd(p0) = t(p0) = 350 TTRnd(p1) = (t(p1) +TTRnd(p0)) = = 475 TTRnd(p2) = (t(p2) +TTRnd(p1)) = = 950 TTRnd(p3) = (t(p3) +TTRnd(p2)) = = 1200 TTRnd(p4) = (t(p4) +TTRnd(p3)) = = 1275 W(p0) = 0 W(p1) = TTRnd(p0) = 350 W(p2) = TTRnd(p1) = 475 W(p3) = TTRnd(p2) = 950 W(p4) = TTRnd(p3) = 1200
44
FCFS Average Wait Time Easy to implement Ignores service time, etc
i t(pi) p0 p1 p2 p3 p4 TTRnd(p0) = t(p0) = 350 TTRnd(p1) = (t(p1) +TTRnd(p0)) = = 475 TTRnd(p2) = (t(p2) +TTRnd(p1)) = = 950 TTRnd(p3) = (t(p3) +TTRnd(p2)) = = 1200 TTRnd(p4) = (t(p4) +TTRnd(p3)) = = 1275 W(p0) = 0 W(p1) = TTRnd(p0) = 350 W(p2) = TTRnd(p1) = 475 W(p3) = TTRnd(p2) = 950 W(p4) = TTRnd(p3) = 1200 Wavg = ( )/5 = 2974/5 = 595 1275 1200 950 475 350 Easy to implement Ignores service time, etc Not a great performer
45
Predicting Wait Time in FCFS
In FCFS, when a process arrives, all in ready list will be processed before this job Let μ be the service rate Let L be the ready list length Wavg(p) = L*1/μ + 0.5* 1/ μ = L/ μ +1/(2 μ) (in queue) (active process) Compare predicted wait with actual in earlier examples
46
First-Come-First-Served – cont.
Example: Process Burst Time P P P Suppose that the processes arrive in the order: P1, P2 , P3 The Gantt Chart for the schedule is: Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: ( )/3 = 17 P1 P2 P3 24 27 30
47
First-Come-First-Served – cont.
Suppose that the processes arrive in the order P2 , P3 , P1 The Gantt chart for the schedule is: Waiting time for P1 = 6; P2 = 0; P3 = 3 Average waiting time: ( )/3 = 3 Much better than previous case. P1 P3 P2 6 3 30
48
Shortest-Job-Next Scheduling
Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. SJN is optimal gives minimum average waiting time for a given set of processes.
49
Shortest-Job-Next Scheduling – cont.
Two schemes: non-preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst. Preemptive – 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-Next (SRTN).
50
Shortest Job Next (nonpreemptive)
i t(pi) 75 p4 TTRnd(p4) = t(p4) = 75 W(p4) = 0
51
Shortest Job Next – cont.
i t(pi) 75 200 p4 p1 TTRnd(p1) = t(p1)+t(p4) = = 200 TTRnd(p4) = t(p4) = 75 W(p1) = 75 W(p4) = 0
52
Shortest Job Next – cont.
i t(pi) 75 200 450 p4 p1 p3 TTRnd(p1) = t(p1)+t(p4) = = 200 TTRnd(p3) = t(p3)+t(p1)+t(p4) = = 450 TTRnd(p4) = t(p4) = 75 W(p1) = 75 W(p3) = 200 W(p4) = 0
53
Shortest Job Next – cont.
i t(pi) 75 200 450 800 p4 p1 p3 p0 TTRnd(p0) = t(p0)+t(p3)+t(p1)+t(p4) = = 800 TTRnd(p1) = t(p1)+t(p4) = = 200 TTRnd(p3) = t(p3)+t(p1)+t(p4) = = 450 TTRnd(p4) = t(p4) = 75 W(p0) = 450 W(p1) = 75 W(p3) = 200 W(p4) = 0
54
Shortest Job Next – cont.
i t(pi) 75 200 450 800 1275 p4 p1 p3 p0 p2 TTRnd(p0) = t(p0)+t(p3)+t(p1)+t(p4) = = 800 TTRnd(p1) = t(p1)+t(p4) = = 200 TTRnd(p2) = t(p2)+t(p0)+t(p3)+t(p1)+t(p4) = = 1275 TTRnd(p3) = t(p3)+t(p1)+t(p4) = = 450 TTRnd(p4) = t(p4) = 75 W(p0) = 450 W(p1) = 75 W(p2) = 800 W(p3) = 200 W(p4) = 0
55
Shortest Job Next – cont.
i t(pi) Minimizes wait time May starve large jobs Must know service times 75 200 450 800 1275 p4 p1 p3 p0 p2 W(p0) = 450 W(p1) = 75 W(p2) = 800 W(p3) = 200 W(p4) = 0 TTRnd(p0) = t(p0)+t(p3)+t(p1)+t(p4) = = 800 TTRnd(p1) = t(p1)+t(p4) = = 200 TTRnd(p2) = t(p2)+t(p0)+t(p3)+t(p1)+t(p4) = = 1275 TTRnd(p3) = t(p3)+t(p1)+t(p4) = = 450 TTRnd(p4) = t(p4) = 75 Wavg = ( )/5 = 1525/5 = 305
56
Determining Length of Next CPU Burst
Can only estimate the length. Can be done by using the length of previous CPU bursts, using exponential averaging.
57
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.
58
Priority Scheduling In priority scheduling, processes/threads are allocated to the CPU based on the basis of an externally assigned priority A commonly used convention is that lower numbers have higher priority Static priorities vs. dynamic priorities Static priorities are computed once at the beginning and are not changed Dynamic priorities allow the threads to become more or less important depending on how much service it has recently received
59
Priority Scheduling – cont.
There are non-preemptive and preemptive priority scheduling algorithms Preemptive nonpreemptive SJN is a priority scheduling where priority is the predicted next CPU burst time. FCFS is a priority scheduling where priority is the arrival time
60
Non-preemptive Priority Scheduling
i t(pi) Pri Reflects importance of external use May cause starvation Can address starvation with aging 250 375 850 925 1275 p3 p1 p2 p4 p0 TTRnd(p0) = t(p0)+t(p4)+t(p2)+t(p1) )+t(p3) = = 1275 TTRnd(p1) = t(p1)+t(p3) = = 375 TTRnd(p2) = t(p2)+t(p1)+t(p3) = = 850 TTRnd(p3) = t(p3) = 250 TTRnd(p4) = t(p4)+ t(p2)+ t(p1)+t(p3) = = 925 TTRnd = ( )/5 = 735 W(p0) = 925 W(p1) = 250 W(p2) = 375 W(p3) = 0 W(p4) = 850 Wavg = ( )/5 = 2400/5 = 480
61
Deadline Scheduling Allocates service by deadline May not be feasible
i t(pi) Deadline (none) p0 p1 p2 p3 p4 1275 1050 550 200 Allocates service by deadline May not be feasible 575
62
Real-Time Scheduling Hard real-time systems – required to complete a critical task within a guaranteed amount of time. Soft real-time computing – requires that critical processes receive priority over less fortunate ones.
63
Preemptive Schedulers
Ready List Scheduler CPU Preemption or voluntary yield Done New Process Highest priority process is guaranteed to be running at all times Or at least at the beginning of a time slice Dominant form of contemporary scheduling But complex to build & analyze
64
Preemptive Shortest Job Next
Also called the shortest remaining job next When a new process arrives, its next CPU burst is compared to the remaining time of the running process If the new arriver’s time is shorter, it will preempt the CPU from the current running process
65
Example of Preemptive SJF
Process Arrival Time Burst Time P P P P Average time spent in ready queue = ( )/4 = 3 P1 P3 P2 4 2 11 P4 5 7 16
66
Comparison of Non-Preemptive and Preemptive SJF
Process Arrival Time Burst Time P P P P SJN (non-preemptive) Average time spent in ready queue ( )/4 = 4 P1 P3 P2 7 3 16 P4 8 12
67
Round Robin (RR) Each process gets a small unit of CPU time (time quantum), usually milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
68
Round-robin scheduling
Good way to upset customers!
69
Round Robin (TQ=50) i t(pi) 0 350 1 125 2 475 3 250 4 75 W(p0) = 0 50
50 p0 W(p0) = 0
70
Round Robin (TQ=50) – cont.
i t(pi) 100 p0 p1 W(p0) = 0 W(p1) = 50
71
Round Robin (TQ=50) – cont.
i t(pi) 100 p0 p1 p2 W(p0) = 0 W(p1) = 50 W(p2) = 100
72
Round Robin (TQ=50) – cont.
i t(pi) 100 200 p0 p1 p2 p3 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150
73
Round Robin (TQ=50) – cont.
i t(pi) 100 200 p0 p1 p2 p3 p4 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
74
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 p0 p1 p2 p3 p4 p0 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
75
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 400 475 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
76
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 400 475 550 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 TTRnd(p1) = 550 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
77
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 400 475 550 650 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 p2 p3 650 750 850 950 p0 p2 p3 p0 p2 p3 TTRnd(p1) = 550 TTRnd(p3) = 950 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
78
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 400 475 550 650 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 p2 p3 650 750 850 950 1050 p0 p2 p3 p0 p2 p3 p0 p2 p0 TTRnd(p0) = 1100 TTRnd(p1) = 550 TTRnd(p3) = 950 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
79
Round Robin (TQ=50) – cont.
i t(pi) 100 200 300 400 475 550 650 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 p2 p3 650 750 850 950 1050 1150 1250 1275 p0 p2 p3 p0 p2 p3 p0 p2 p0 p2 p2 p2 p2 TTRnd(p0) = 1100 TTRnd(p1) = 550 TTRnd(p2) = 1275 TTRnd(p3) = 950 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200
80
Round Robin (TQ=50) – cont.
i t(pi) p0 TTRnd(p0) = 1100 TTRnd(p1) = 550 TTRnd(p2) = 1275 TTRnd(p3) = 950 TTRnd(p4) = 475 W(p0) = 0 W(p1) = 50 W(p2) = 100 W(p3) = 150 W(p4) = 200 Wavg = ( )/5 = 500/5 = 100 475 400 300 200 100 Equitable Most widely-used Fits naturally with interval timer p4 p1 p3 p2 550 650 750 850 950 1050 1150 1250 1275 TTRnd_avg = ( )/5 = 4350/5 = 870
81
Round Robin – cont. Performance q large FIFO
q small q must be large with respect to context switch, otherwise overhead is too high.
82
Turnaround Time Varies With The Time Quantum
83
How a Smaller Time Quantum Increases Context Switches
84
Round Robin (TQ=50) – cont.
Overhead must be considered i t(pi) p0 TTRnd(p0) = 1320 TTRnd(p1) = 660 TTRnd(p2) = 1535 TTRnd(p3) = 1140 TTRnd(p4) = 565 W(p0) = 0 W(p1) = 60 W(p2) = 120 W(p3) = 180 W(p4) = 240 Wavg = ( )/5 = 600/5 = 120 540 480 360 240 120 p4 p1 p3 p2 575 790 910 1030 1150 1270 1390 1510 1535 TTRnd_avg = ( )/5 = 5220/5 = 1044 635 670
85
Multi-Level Queues Each list may use a different policy FCFS SJN RR
Preemption or voluntary yield Ready List0 New Process Scheduler Ready List1 CPU Done Ready List2 Each list may use a different policy FCFS SJN RR Ready Listn
86
Multilevel Queues Ready queue is partitioned into separate queues
foreground (interactive) background (batch) Each queue has its own scheduling algorithm foreground – RR background – FCFS
87
Multilevel Queues – cont.
Scheduling must be done 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
88
Multilevel Queue Scheduling
89
Multilevel Feedback Queue
A process can move between the various queues; aging can be implemented this way. Multilevel-feedback-queue scheduler defined by the following parameters: number of queues scheduling algorithms for each queue method used to determine when to upgrade a process method used to determine when to demote a process method used to determine which queue a process will enter when that process needs service
90
Multilevel Feedback Queues – cont.
91
Example of Multilevel Feedback Queue
Three queues: Q0 – time quantum 8 milliseconds Q1 – 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.
92
Two-queue scheduling
93
Three-queue scheduling
94
Multiple-Processor Scheduling
CPU scheduling more complex when multiple CPUs are available. Homogeneous processors within a multiprocessor. Load sharing Asymmetric multiprocessing – only one processor accesses the system data structures, alleviating the need for data sharing.
95
Algorithm Evaluation Deterministic modeling – takes a particular predetermined workload and defines the performance of each algorithm for that workload. Queuing models Implementation
96
Evaluation of CPU Schedulers by Simulation
97
Contemporary Scheduling
Involuntary CPU sharing -- timer interrupts Time quantum determined by interval timer -- usually fixed for every process using the system Sometimes called the time slice length Priority-based process (job) selection Select the highest priority process Priority reflects policy With preemption Usually a variant of Multi-Level Queues
98
Scheduling in real OSs All use a multiple-queue system
UNIX SVR4: 160 levels, three classes time-sharing, system, real-time Solaris: 170 levels, four classes time-sharing, system, real-time, interrupt OS/2 2.0: 128 level, four classes background, normal, server, real-time Windows NT 3.51: 32 levels, two classes regular and real-time Mach uses “hand-off scheduling”
99
BSD 4.4 Scheduling Involuntary CPU Sharing Preemptive algorithms
32 Multi-Level Queues Queues 0-7 are reserved for system functions Queues 8-31 are for user space functions nice influences (but does not dictate) queue level
100
Windows NT/2K/XP Scheduling
Involuntary CPU Sharing across threads Preemptive algorithms 32 Multi-Level Queues Highest 16 levels are “real-time” Next lower 15 are for system/user threads Range determined by process base priority Lowest level is for the idle thread
101
Scheduler in Linux In file kernel/sched.c
The policy is a variant of RR scheduling
102
Summary The scheduler is responsible for multiplexing the CPU among a set of ready processes / threads It is invoked periodically by a timer interrupt, by a system call, other device interrupts, any time that the running process terminates It selects from the ready list according to its scheduling policy Which includes non-preemptive and preemptive algorithms
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.