intro to o/s scheduling
DESCRIPTION
Intro to O/S Scheduling. 1. Intro to O/S Scheduling 2. What is Scheduling? 3. Computer Systems Scheduling 4. O/S Scheduling Categories 5. O/S Scheduling and Process State 6. O/S Scheduling Layers 7. Scheduling Algorithm Criteria 8. Introduction to Performance - PowerPoint PPT PresentationTRANSCRIPT
Intro to O/S SchedulingIntro to O/S Scheduling
1. Intro to O/S Scheduling2. What is Scheduling?3. Computer Systems Scheduling4. O/S Scheduling Categories5. O/S Scheduling and Process State6. O/S Scheduling Layers7. Scheduling Algorithm Criteria8. Introduction to Performance9. Time as a Performance Metric10. Rate as a Performance Metric11. Response Time and Throughput
1. Intro to O/S Scheduling2. What is Scheduling?3. Computer Systems Scheduling4. O/S Scheduling Categories5. O/S Scheduling and Process State6. O/S Scheduling Layers7. Scheduling Algorithm Criteria8. Introduction to Performance9. Time as a Performance Metric10. Rate as a Performance Metric11. Response Time and Throughput
12. Utilization as a Performance Measurement13. Queuing Notation14. How Preemption Fits in15. FCFS Defined16. FCFS Examples17. FCFS analyzed18. SJF Example19. SJF Features20. Estimating Service Time21. SRT22. HRRN Scheduling
12. Utilization as a Performance Measurement13. Queuing Notation14. How Preemption Fits in15. FCFS Defined16. FCFS Examples17. FCFS analyzed18. SJF Example19. SJF Features20. Estimating Service Time21. SRT22. HRRN Scheduling
Intro to O/S Scheduling (continued)Intro to O/S Scheduling (continued)
23. RR Scheduling24. RR Example25. RR Tq and System Turnaround Time26. RR Tq and E[Tq]27. RR Example Tq = 128. RR Example Tq = 1029. RR Example Tq = 10030. RR Example Tq = 3031. RR Features Summary
23. RR Scheduling24. RR Example25. RR Tq and System Turnaround Time26. RR Tq and E[Tq]27. RR Example Tq = 128. RR Example Tq = 1029. RR Example Tq = 10030. RR Example Tq = 3031. RR Features Summary
Intro to O/S Scheduling (continued)Intro to O/S Scheduling (continued)
What is Scheduling?What is Scheduling?
Many definitions exist, our on-line Webster server came up with:
1. to appoint, assign, or designate for a fixed time
2. a procedural plan that indicates the time and sequence of each operation
Many definitions exist, our on-line Webster server came up with:
1. to appoint, assign, or designate for a fixed time
2. a procedural plan that indicates the time and sequence of each operation
What is Scheduling? (continued)What is Scheduling? (continued)
Scheduling is an open research area, studied in engineering, decision sciences, operations research, and mathematics.
This lecture focuses on O/S level scheduling in uniprocessor computer systems.
Scheduling is an open research area, studied in engineering, decision sciences, operations research, and mathematics.
This lecture focuses on O/S level scheduling in uniprocessor computer systems.
Computer Systems SchedulingComputer Systems Scheduling
In a computer system typically there are:
1. Servers which respond to processes' requests for service (e.g. I/O, CPU, Data Communication, adders, bus, etc.).
2. Requests are serviced in order of their Priority, with highest priority jobs going first.
In a computer system typically there are:
1. Servers which respond to processes' requests for service (e.g. I/O, CPU, Data Communication, adders, bus, etc.).
2. Requests are serviced in order of their Priority, with highest priority jobs going first.
3. A preemption occurs if a server: a) Partially services a request, say b) Preserves partial results of service for A c) Begins/resumes servicing another request with higher priority, say B d) The server will later resume servicing.
The computer systems scheduling primitives address these issues.
3. A preemption occurs if a server: a) Partially services a request, say b) Preserves partial results of service for A c) Begins/resumes servicing another request with higher priority, say B d) The server will later resume servicing.
The computer systems scheduling primitives address these issues.
Computer Systems SchedulingComputer Systems Scheduling
O/S Scheduling CategoriesO/S Scheduling Categories
1. Long Term Scheduling - Which Jobs to add to the Processing
2. Medium Term Scheduling -Which process to load into
memory
3. Short Term Scheduling - Which ready process gets
the CPU
4. I/O Term Scheduling - Which pending I/O request
does an I/O device service.
1. Long Term Scheduling - Which Jobs to add to the Processing
2. Medium Term Scheduling -Which process to load into
memory
3. Short Term Scheduling - Which ready process gets
the CPU
4. I/O Term Scheduling - Which pending I/O request
does an I/O device service.
O/S Scheduling and Process StateO/S Scheduling and Process State
New
Ready,Suspended Ready Running
Long- Term Scheduling
ExitEvent Wait
BlockedBlocked, Suspended
Medium- Term Scheduling
Medium- Term Scheduling
Short- Term Scheduling
Long- Term Scheduling
O/S Scheduling LayersO/S Scheduling Layers
The long term scheduling primitives are supported by the ``low level'' short term scheduling primitives.The long term scheduling primitives are supported by the ``low level'' short term scheduling primitives.
runready
short term
ready
transput waitmain-store wait
medium
readylong term
Figure 2: Scheduling Layers Transput denotes I/O
Figure 2: Scheduling Layers Transput denotes I/O
O/S Scheduling LayersO/S Scheduling Layers
Queuing discipline reflects scheduling.
Queuing discipline reflects scheduling.
Figure 6Figure 6
Scheduling Algorithm CriteriaScheduling Algorithm Criteria
The following issues impact scheduling algorithm selection:
1. Feasibility of computation2. Feasibility of schedule
3. Efficiency of computation
4. Efficiency of schedule
5. Ease of implementation
Both qualitative and quantitative issues matter.
The following issues impact scheduling algorithm selection:
1. Feasibility of computation2. Feasibility of schedule
3. Efficiency of computation
4. Efficiency of schedule
5. Ease of implementation
Both qualitative and quantitative issues matter.
Scheduling Algorithm CriteriaScheduling Algorithm Criteria
Stallings [3] gives the following schedulingcriteria:
1. User Oriented - Performance
a) Response Time
b) Turnaround Time
c) Deadlines
2. User Oriented - Other Criteria - Predictability
Stallings [3] gives the following schedulingcriteria:
1. User Oriented - Performance
a) Response Time
b) Turnaround Time
c) Deadlines
2. User Oriented - Other Criteria - Predictability
3. Systemic Performance
a) Throughput
b) Processor Utilization
4. Systemic - Other Performance
a) Fairness
b) Enforcing Priorities
c) Balancing Resources
3. Systemic Performance
a) Throughput
b) Processor Utilization
4. Systemic - Other Performance
a) Fairness
b) Enforcing Priorities
c) Balancing Resources
Scheduling Algorithm CriteriaScheduling Algorithm Criteria
Introduction to PerformanceIntroduction to Performance
Performance denotes computational speed measurements and is sensitive to scheduling efficiency.
Categories of classic performance measures:
1. Time (e.g. response time)
2. Rate (e.g. throughput)
3. Resource (e.g. utilization)
Performance denotes computational speed measurements and is sensitive to scheduling efficiency.
Categories of classic performance measures:
1. Time (e.g. response time)
2. Rate (e.g. throughput)
3. Resource (e.g. utilization)
Time as a Performance MetricTime as a Performance Metric
There are intervals in user/computer interaction:1. Response time --- Time until either: a) System Begins Response, or b) System Ends Response2. Reaction time --- User Latency3. Turnaround Time --- Process Duration4. Think Time --- User Latency 5. Stretch Factor --- Reaction of system to a fixed increased load
There are intervals in user/computer interaction:1. Response time --- Time until either: a) System Begins Response, or b) System Ends Response2. Reaction time --- User Latency3. Turnaround Time --- Process Duration4. Think Time --- User Latency 5. Stretch Factor --- Reaction of system to a fixed increased load
Figure 4: Definitions of Response Time
Figure 4: Definitions of Response Time
Rate as a Performance MetricRate as a Performance Metric
Owners of computers want to know the throughput (Operations/ Time) of the system:
1. Processing- MIPS, MFLOPS, GFLOPS, TFLOPS, Sustained, Peak2. I/O- (Transactions/ Second), Bandwidth3. Network/Data Communications- Bandwidth, bps, fps, Mbps, pps4. Efficiency- Measures Achieved Throughput Available Throughput
Owners of computers want to know the throughput (Operations/ Time) of the system:
1. Processing- MIPS, MFLOPS, GFLOPS, TFLOPS, Sustained, Peak2. I/O- (Transactions/ Second), Bandwidth3. Network/Data Communications- Bandwidth, bps, fps, Mbps, pps4. Efficiency- Measures Achieved Throughput Available Throughput
Figure 5: Efficiency of a Multiprocessor SystemFigure 5: Efficiency of a Multiprocessor System
Response Time and ThroughputResponse Time and Throughput
Figure 6: Response Time vs. Throughput
Figure 6: Response Time vs. Throughput
Utilization as a Performance Measurement
Utilization as a Performance Measurement
Expensive computing resources should be used.
1. Idle Time --- How long the resources are unused
2. Utilization --- The ratio: Time Used Total Time
Expensive computing resources should be used.
1. Idle Time --- How long the resources are unused
2. Utilization --- The ratio: Time Used Total Time
Figure 7: Meaning of Time MeasurementsFigure 7: Meaning of Time Measurements
Queuing NotationQueuing Notation
Symbol
TqTs
Meaning
Turn Around TimeService Time
Table 1: NotationTable 1: Notation
How Preemption Fits InHow Preemption Fits In
Symbol
Arrival Time in the systemContext Switch CostTime Waiting Queue
TaTcTw
Meaning
Table 2: Extended notationTable 2: Extended notation
Figure 8: Preemption and Time MeasurementsFigure 8: Preemption and Time Measurements
FCFS DefinedFCFS Defined
First Come First Serve (FCFS) scheduling:
1. is nonpreemptive
2. uses a FIFO queue
First Come First Serve (FCFS) scheduling:
1. is nonpreemptive
2. uses a FIFO queue
An FCFS ExampleAn FCFS Example
Figure 9: FCFS Example Time LineFigure 9: FCFS Example Time Line
Table 3: Example FCFS Job SchedulesTable 3: Example FCFS Job Schedules
Jobs
TaId Ts TaTq Tq
Case 2Case 1
A 30
B 60
C 210
20 280
10 260
0 210
0 30
10 80
20 280
FCFS AnalyzedFCFS Analyzed
The throughput is 1/E[Tq] solving for E[Tq]: • Case 1: E[Tq]= (280+260+210) / 3 = 250• Case 2: E[Tq]= (30+80+280) / 3 = 130Some characteristics of FCFS scheduling:1. Penalizes short jobs2. Rewards long jobs3. Large variance in throughput4. Sensitive to order of arrival5. Is starvation free6. Easy to implement
The throughput is 1/E[Tq] solving for E[Tq]: • Case 1: E[Tq]= (280+260+210) / 3 = 250• Case 2: E[Tq]= (30+80+280) / 3 = 130Some characteristics of FCFS scheduling:1. Penalizes short jobs2. Rewards long jobs3. Large variance in throughput4. Sensitive to order of arrival5. Is starvation free6. Easy to implement
SJF (also called SPN)SJF (also called SPN)
Shortest Job First (SJF) is also calledShortest Process Next (SPN):
1. Services jobs in ascending order
2. Is non-preemptive
Shortest Job First (SJF) is also calledShortest Process Next (SPN):
1. Services jobs in ascending order
2. Is non-preemptive
SJF ExampleSJF Example
Consider the same jobs again:Consider the same jobs again:
Figure 10: SJF Example Time LineFigure 10: SJF Example Time Line
Jobs
TaId Ts TaTq
Case 2Case 1
A 30
B 60
C 210
20 220
10 290
0 210
0 30
10 80
20 280
Tq
Table 4: Example SJF Job SchedulesTable 4: Example SJF Job Schedules
SJF FeaturesSJF Features
Recall that throughput is 1/E[Tq] solving for E[Tq]:• Case 1: E[Tq] = (220+290+210) / 3 = 240• Case 2: E[Tq] = (30+80+280) / 3 = 140Some characteristics of SJF scheduling:1. Penalizes long jobs2. Rewards short jobs3. Somewhat sensitive to order of arrival4. Gives optimal nonpreemptive throughput 5. Permits Starvation6. Knowing Ts difficult
Recall that throughput is 1/E[Tq] solving for E[Tq]:• Case 1: E[Tq] = (220+290+210) / 3 = 240• Case 2: E[Tq] = (30+80+280) / 3 = 140Some characteristics of SJF scheduling:1. Penalizes long jobs2. Rewards short jobs3. Somewhat sensitive to order of arrival4. Gives optimal nonpreemptive throughput 5. Permits Starvation6. Knowing Ts difficult
Estimating Service TimeEstimating Service Time
Let Sn be the estimate for a job's nth service time,
Tn, for a process.
Let , 0< <1 be a tuning parameter.
Sn+1 = (1 - ) Sn + Tn
= (1 - )n So + sum((1- )(n - i) Ti-1)(from i=1 to n+1)
Let Sn be the estimate for a job's nth service time,
Tn, for a process.
Let , 0< <1 be a tuning parameter.
Sn+1 = (1 - ) Sn + Tn
= (1 - )n So + sum((1- )(n - i) Ti-1)(from i=1 to n+1)
Estimating Service Time (continued)Estimating Service Time (continued)
When computing the estimate Sn:
= 0 disregard Tn in estimate.
= 1 only Tn impacts estimate.
0< <1 older Tn and initial guess So
eventually get discounted (at an
exponential rate).
When computing the estimate Sn:
= 0 disregard Tn in estimate.
= 1 only Tn impacts estimate.
0< <1 older Tn and initial guess So
eventually get discounted (at an
exponential rate).
SRTSRT
In SJF servicing long jobs forces shorter newly arrived jobs to wait.
Shortest Remaining Time (SRT) is a preemptive version of SJF.
1. Service Times may be estimated.2. Favor jobs with smaller Tq.
The heuristic presented may be used to estimate Tn.
In SJF servicing long jobs forces shorter newly arrived jobs to wait.
Shortest Remaining Time (SRT) is a preemptive version of SJF.
1. Service Times may be estimated.2. Favor jobs with smaller Tq.
The heuristic presented may be used to estimate Tn.
HRRN SchedulingHRRN Scheduling
Highest Response Ratio Next (HRRN):1. is non preemptive2. is starvation free3. jobs are serviced in descending Response Ratio RR order.4. estimating service time, Ts, may be required.5. Requires Frequent Recomputation of Priorities6. is more fair than FCFS
Response Ratio for a given processes nth service of duration Tn after waiting w duration for service is:
RR(n) = w + Tn
Tn
Estimating Tn can be done as shown earlier.
Response Ratio for a given processes nth service of duration Tn after waiting w duration for service is:
RR(n) = w + Tn
Tn
Estimating Tn can be done as shown earlier.
HRRN SchedulingHRRN Scheduling
RR SchedulingRR Scheduling
Round Robin (RR) scheduling:
1. Is Preemptive
2. Services jobs in FIFO order
The max time to preemption is the quantum, Tq.
Round Robin (RR) scheduling:
1. Is Preemptive
2. Services jobs in FIFO order
The max time to preemption is the quantum, Tq.
RR ExampleRR Example
Let the context switch time is Tc = 5.Let the context switch time is Tc = 5.
See how 0< Tq < 210 impacts performance.See how 0< Tq < 210 impacts performance.
Id Ts T
A 30 20
B 60 10
C 210 0
Table 5: RR Job ExampleTable 5: RR Job Example
RR and System Turnaround TimeRR and System Turnaround Time
Preemption increases system turnaround time (max{Tq}) rewards large Tq (FCFS approximation).Preemption increases system turnaround time (max{Tq}) rewards large Tq (FCFS approximation).
Figure 11: System Turnaround Time as a function of Tq
Figure 11: System Turnaround Time as a function of Tq
RR TQ and E [Tq]RR TQ and E [Tq]
The mean turnaround time for a job E [Tq] The mean turnaround time for a job E [Tq]
Figure 12: E[Tq] as a function of Tq
Figure 12: E[Tq] as a function of Tq
RR Example TQ = 1RR Example TQ = 1
Tq = 1 is far too small a time slice, usually Tq >> TcTq = 1 is far too small a time slice, usually Tq >> Tc
Figure 13: RR Scheduling Example for Tq = 1
Figure 13: RR Scheduling Example for Tq = 1
RR Example TQ = 10RR Example TQ = 10
Tq = 10 is still a bit too small a time slice.Tq = 10 is still a bit too small a time slice.
Figure 14: RR Scheduling Example for Tq = 10
Figure 14: RR Scheduling Example for Tq = 10
RR Example TQ = 100RR Example TQ = 100
Tq = 100 is a bit too large to be a good time slice, typically Tq < E[Tq].Tq = 100 is a bit too large to be a good time slice, typically Tq < E[Tq].
Figure 15: RR Scheduling Example for Tq=100
Figure 15: RR Scheduling Example for Tq=100
RR Example TQ = 30RR Example TQ = 30
Tq = 30 seems to be a good time slice.Tq = 30 seems to be a good time slice.
Figure 16: RR Scheduling Example for Tq = 30
Figure 16: RR Scheduling Example for Tq = 30
RR Features SummaryRR Features Summary
Some characteristics of RR scheduling:
1. Preemptive (at quantum ).2. Less Sensitive to order of arrival.3. Quantum should not be too small .4. Sensitive to overly large (approximates FCFS).5. Low overhead.6. Starvation Impossible.
Some characteristics of RR scheduling:
1. Preemptive (at quantum ).2. Less Sensitive to order of arrival.3. Quantum should not be too small .4. Sensitive to overly large (approximates FCFS).5. Low overhead.6. Starvation Impossible.