processor scheduling
DESCRIPTION
Processor Scheduling. Scheduling is the activity of selecting the next Job / Process / Request to be handled by a Server/CPU. Preemption Scheduling : A request being processed is preempted in order to provide service to other requests in the system. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/1.jpg)
OS/ProcSche/NI2008 1
Processor SchedulingScheduling is the activity of selecting the next Job / Process / Request to be handled by a Server/CPU.Preemption Scheduling: A request being processed is preempted in order to provide service to other requests in the system. It is for providing fair services to all the requests, or servicing the superior request. Non Preemptive Scheduling: A non preemptive scheduling / server always processes a scheduled request / job to completion.
![Page 2: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/2.jpg)
OS/ProcSche/NI2008 2
CPU scheduling criteria CPU Utilization – Percentage of Time that the processor
is busy.
Throughput – how many jobs finished/unit time?• No of processes completed per unit of time.
Turnaround Time – how long from job submission to job termination?
Interval of time between the submission of a process and its completion. Includes actual execution time + time spent waiting for resources, including the processor.
Response Time – how long (on average) does it take to get a “response”?
For an interactive process, this is the time from submission of a request/job until the response begins to be received.
Missed deadlines – were any deadlines missed?
![Page 3: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/3.jpg)
OS/ProcSche/NI2008 3
CPU scheduling criteria
Delay Time / CPU Latency Time: Delay caused in selecting a process for execution
Burst/Service Time: Actual time taken by CPU to completes the process
Weighted Turn around time: Ratio of the turn around time of a job/process to its
own execution requirements. Deadline:
Time by which a job/process must be completed Deadline Overrun:
The amount of time by which the deadline of a job/process is exceeded. It can be both positive or negative.
Schedule Length: The total time taken to complete a set of jobs/processes submitted to a server.
![Page 4: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/4.jpg)
OS/ProcSche/NI2008 4
Scheduler options Priorities
May use priorities to determine who runs next
• Amount of memory, Order of arrival, etc.. Dynamic vs. Static algorithms
• Dynamically alter the priority of the tasks while they are in the system (possibly with feedback)
• Static algorithms typically assign a fixed priority when the job is initially started.
Preemptive vs. Nonpreemptive Preemptive systems allow the task to be
interrupted at any time so that the O.S. can take over again.
![Page 5: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/5.jpg)
OS/ProcSche/NI2008 5
Types of Scheduling Scheduling is split into three
steps/levels/stages Long Term Scheduling / Admission Scheduler
– ( New state / Admit state) to Ready Medium Term Scheduling / Memory Scheduler
– ( Ready / Suspended / Blocked / waiting) Short Term Scheduler / CPU scheduler
– ( Preemptive / Non-Preemptive)– ( Ready to Running State)
![Page 6: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/6.jpg)
OS/ProcSche/NI2008 6
Types of Scheduling Long Term Scheduling:
• When to initiate the processing of a job / process. Which programs are admitted to the system for processing. The others are kept in the input queue until they are selected.
• Allocates necessary resources • Make it ready to send to the Medium Term Scheduler.
Medium Term Scheduler:• MTS keeps track of states of processes admitted for
processing and prepares for execution on the CPU. • It determines which processes should be kept in
memory and which one kept on disk (virtual memory). • The decision to add to the number of processes that
are partially or fully in main memory. • Performs memory swapping in/out.
![Page 7: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/7.jpg)
OS/ProcSche/NI2008 7
Types of Scheduling Short Term Scheduling: The short term scheduler is
invoked whenever an event occurs that may lead to the suspension of the current process or that may provide an opportunity to preempt a currently running process in favor of another. Event are .
• Clock interrupts• I/O interrupts• Operating system calls • Signals
STS picks one process from the list of ready processes for execution on the CPU, and hands it to the Dispatching Mechanism. Dispatching loads the state of the selected process – contents of the PSW and CPU registers – into the CPU and allows the CPU to resume execution of the process.
![Page 8: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/8.jpg)
8
![Page 9: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/9.jpg)
OS/ProcSche/NI2008 9
Scheduling policies / Algorithms First-Come, First Served (FIFO) Shortest Job First (non-preemeptive) Shortest Job First (with preemption)
( Shortest Remaining Time Next ) Highest Response Ratio Next Scheduling Shortest Job Next Deadline Scheduling Priority Scheduling Real-Time Scheduling Round-Robin Scheduling
![Page 10: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/10.jpg)
OS/ProcSche/NI2008 10
Scheduling policies (Preemptive)
Round Robin Scheduling Heavily loaded system Two Queues Multiple Queues Guaranteed Scheduling Lottery Scheduling Fair Share scheduling
![Page 11: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/11.jpg)
OS/ProcSche/NI2008 11
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
![Page 12: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/12.jpg)
OS/ProcSche/NI2008 12
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 13: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/13.jpg)
OS/ProcSche/NI2008 13
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 14: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/14.jpg)
OS/ProcSche/NI2008 14
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
Arrival Times of the Jobs
![Page 15: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/15.jpg)
OS/ProcSche/NI2008 15
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 16: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/16.jpg)
OS/ProcSche/NI2008 16
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 17: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/17.jpg)
OS/ProcSche/NI2008 17
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 18: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/18.jpg)
OS/ProcSche/NI2008 18
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 19: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/19.jpg)
OS/ProcSche/NI2008 19
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 20: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/20.jpg)
OS/ProcSche/NI2008 20
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 21: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/21.jpg)
OS/ProcSche/NI2008 21
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 22: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/22.jpg)
OS/ProcSche/NI2008 22
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 23: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/23.jpg)
OS/ProcSche/NI2008 23
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 24: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/24.jpg)
OS/ProcSche/NI2008 24
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 25: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/25.jpg)
OS/ProcSche/NI2008 25
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 26: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/26.jpg)
OS/ProcSche/NI2008 26
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Total time taken,from submission to
completion
![Page 27: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/27.jpg)
OS/ProcSche/NI2008 27
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 5 4 6 5 7 5 8 2 10
Total time taken,from submission to
completion
![Page 28: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/28.jpg)
OS/ProcSche/NI2008 28
First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 5 9 4 6 5 7 12 5 8 2 10 12
Total time taken,from submission to
completion
![Page 29: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/29.jpg)
OS/ProcSche/NI2008 29
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
![Page 30: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/30.jpg)
OS/ProcSche/NI2008 30
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Same Job Mix
![Page 31: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/31.jpg)
OS/ProcSche/NI2008 31
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 32: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/32.jpg)
OS/ProcSche/NI2008 32
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 33: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/33.jpg)
OS/ProcSche/NI2008 33
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 34: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/34.jpg)
OS/ProcSche/NI2008 34
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 35: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/35.jpg)
OS/ProcSche/NI2008 35
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 36: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/36.jpg)
OS/ProcSche/NI2008 36
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 37: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/37.jpg)
OS/ProcSche/NI2008 37
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 38: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/38.jpg)
OS/ProcSche/NI2008 38
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 39: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/39.jpg)
OS/ProcSche/NI2008 39
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 40: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/40.jpg)
OS/ProcSche/NI2008 40
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 41: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/41.jpg)
OS/ProcSche/NI2008 41
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 42: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/42.jpg)
OS/ProcSche/NI2008 42
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 43: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/43.jpg)
OS/ProcSche/NI2008 43
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1
![Page 44: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/44.jpg)
OS/ProcSche/NI2008 44
Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3
![Page 45: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/45.jpg)
OS/ProcSche/NI2008 45
Shortest Remaining Time Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Same Job Mix
![Page 46: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/46.jpg)
OS/ProcSche/NI2008 46
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 47: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/47.jpg)
OS/ProcSche/NI2008 47
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 48: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/48.jpg)
OS/ProcSche/NI2008 48
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 49: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/49.jpg)
OS/ProcSche/NI2008 49
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 50: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/50.jpg)
OS/ProcSche/NI2008 50
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 51: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/51.jpg)
OS/ProcSche/NI2008 51
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 52: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/52.jpg)
OS/ProcSche/NI2008 52
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 53: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/53.jpg)
OS/ProcSche/NI2008 53
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 54: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/54.jpg)
OS/ProcSche/NI2008 54
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 55: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/55.jpg)
OS/ProcSche/NI2008 55
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 56: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/56.jpg)
OS/ProcSche/NI2008 56
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 57: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/57.jpg)
OS/ProcSche/NI2008 57
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 58: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/58.jpg)
OS/ProcSche/NI2008 58
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 59: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/59.jpg)
OS/ProcSche/NI2008 59
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 7 3 4 4 0 4 6 5 9 5 8 2 0
![Page 60: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/60.jpg)
OS/ProcSche/NI2008 60
Shortest Remaining Time• Preemptive version of SJF
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 7 13 3 4 4 0 4 4 6 5 9 14 5 8 2 0 2
![Page 61: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/61.jpg)
5: CPU-Scheduling 61
EXAMPLE DATA:
Process Arrival Service Time Time
1 0 8 2 1 4
3 2 9 4 3 5
0 8 12 21 26
P1 P2 P3 P4
FCFS
Average Turnaround time = ( (8-0) + (12-1) + (21-2) + (26-3) )/4 = 61/4 = 15.25
CPU SCHEDULING
Residence Timeat the CPU
![Page 62: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/62.jpg)
5: CPU-Scheduling 62
Assign each process a priority. Schedule highest priority first. All processes within same priority are FCFS.
Priority may be determined by user or by some default mechanism. The system may determine the priority based on memory requirements, time limits, or other resource usage.
Starvation occurs if a low priority process never runs. Solution: build aging into a variable priority.
Delicate balance between giving favorable response for interactive jobs, but not starving batch jobs.
PRIORITY BASED SCHEDULING:
![Page 63: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/63.jpg)
OS/ProcSche/NI2008 63
Priority scheduling Assign a priority (number) to each process Schedule processes based on their priority Higher priority jobs processes get more CPU
time Managing priorities
Can use “nice” to reduce your priority Can periodically adjust a process’ priority
• Prevents starvation of a lower priority process• Can improve performance of I/O-bound
processes by basing priority on fraction of last quantum used
![Page 64: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/64.jpg)
Priority scheduling
Idea: Each job is assigned a priority Schedule highest priority ready job May be preemptive or non-preemptive Priority may be static or dynamic
Advantages Static priorities work well for real time systems Dynamic priorities work well for general workloads
Disadvantages Low priority jobs can starve How to choose priority of each job?
Goal: Adjust priority of job to match CPU burst
Approximate SCTF by giving short jobs high priority
![Page 65: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/65.jpg)
Highest Response Ratio Next (HRRN)
Non-preemptive, tries to get best average normalized turnaround time
Depends on Response Ratio• W = time spent waiting• S = expected service time• RR = (W + S) / S
Select process with highest RR Feedback
Starts in high-priority queue, moves down in priority as it executes
Lower-priority queues often given longer time slices Can starve long processes
• Move up processes if they wait too long
![Page 66: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/66.jpg)
66
Highest Response Ratio Next (HRRN)
Choose next process with the greatest Response Ratio
( time spent waiting + expected service time)
expected service time
![Page 67: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/67.jpg)
67
Fair-Share Scheduling
User’s application runs as a collection of processes (threads)
User is concerned about the performance of the application
Need to make scheduling decisions based on process sets
![Page 68: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/68.jpg)
68
Traditional UNIX Scheduling
Multilevel feedback using round robin within each of the priority queues
If a running process does not block or complete within 1 second, it is preempted
Priorities are recomputed once per second
Base priority divides all processes into fixed bands of priority levels
![Page 69: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/69.jpg)
Starvation
Effect on Processes
Overhead
Response Tim
e
Throughput
Preemptive
Selection Function
No
Penalizes short and I/O
processes
Minim
um
May be high
Not
Emphasized
No
Max tim
e w
aiting
FCFS
No
Fair
Low
Good for short
processes
Low if quantum
too sm
all
At tim
e quantum
- Round R
obin
Possible
Penalizes Long processes
Can be H
igh
Good for short
processes
High
No
Shortest process
SPN
Possible
Penalizes long processes
Can be H
igh
Good
High
At arrival
Min tim
e left
SRT
No
Good balance
Can be H
igh
Good
High
No
See Notes
HR
RN
Possible
May favor I/O
bound processes
Can be H
igh
Not
emphaisized
Not
emphaisized
At tim
e quantum
See Notes
Feedback
Characteristics of V
arious Scheduling Policies (Table 9.3, page 402)
![Page 70: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/70.jpg)
OS/ProcSche/NI2008 70
Round-Robin Scheduling
Goal: Enable interactivity Limit the amount of CPU that a process can
have at one time.
Time quantum Amount of time the OS gives a process before
intervention The “time slice” Typically: 1 to 100ms
![Page 71: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/71.jpg)
5: CPU-Scheduling 71
ROUND ROBIN: Use a timer to cause an interrupt after a predetermined time.
Preempts if task exceeds it’s quantum. Train of events
DispatchTime slice occurs OR process suspends on eventPut process on some queue and dispatch next
Use numbers in last example to find queueing and residence times. (Use quantum = 4 sec.)
Definitions:– Context Switch Changing the processor from
running one task (or process) to another. Implies changing memory.
– Processor Sharing Use of a small quantum such that each process runs frequently at speed 1/n.
– Reschedule latency How long it takes from when a process requests to run, until it finally gets control of the CPU.
ROUND ROBIN
![Page 72: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/72.jpg)
5: CPU-Scheduling 72
Choosing a time quantum
Too short - inordinate fraction of the time is spent in context switches.
Too long - reschedule latency is too great. If many processes want the CPU, then it's a long time before a particular process can get the CPU. This then acts like FCFS.
Adjust so most processes won't use their slice. As processors have become faster, this is less of an issue.
ROUND ROBIN
![Page 73: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/73.jpg)
OS/ProcSche/NI2008 73
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 74: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/74.jpg)
OS/ProcSche/NI2008 74
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 75: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/75.jpg)
OS/ProcSche/NI2008 75
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 76: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/76.jpg)
OS/ProcSche/NI2008 76
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 77: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/77.jpg)
OS/ProcSche/NI2008 77
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 78: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/78.jpg)
OS/ProcSche/NI2008 78
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 79: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/79.jpg)
OS/ProcSche/NI2008 79
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 80: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/80.jpg)
OS/ProcSche/NI2008 80
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 81: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/81.jpg)
OS/ProcSche/NI2008 81
Ready List:
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 82: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/82.jpg)
OS/ProcSche/NI2008 82
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 83: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/83.jpg)
OS/ProcSche/NI2008 83
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 84: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/84.jpg)
OS/ProcSche/NI2008 84
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 85: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/85.jpg)
OS/ProcSche/NI2008 85
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 86: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/86.jpg)
OS/ProcSche/NI2008 86
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 87: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/87.jpg)
OS/ProcSche/NI2008 87
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 88: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/88.jpg)
OS/ProcSche/NI2008 88
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 89: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/89.jpg)
OS/ProcSche/NI2008 89
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 90: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/90.jpg)
OS/ProcSche/NI2008 90
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 91: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/91.jpg)
OS/ProcSche/NI2008 91
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 92: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/92.jpg)
OS/ProcSche/NI2008 92
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 93: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/93.jpg)
OS/ProcSche/NI2008 93
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 94: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/94.jpg)
OS/ProcSche/NI2008 94
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 95: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/95.jpg)
OS/ProcSche/NI2008 95
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 96: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/96.jpg)
OS/ProcSche/NI2008 96
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 97: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/97.jpg)
OS/ProcSche/NI2008 97
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 98: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/98.jpg)
OS/ProcSche/NI2008 98
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
Ready List:
![Page 99: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/99.jpg)
OS/ProcSche/NI2008 99
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2
![Page 100: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/100.jpg)
OS/ProcSche/NI2008 100
Round-Robin Scheduling•
0 5 10 15 20
Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 1 4 2 2 6 10 16 3 4 4 9 13 4 6 5 9 14 5 8 2 5 7
![Page 101: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/101.jpg)
OS/ProcSche/NI2008 101
Round-Robin Scheduling
Effectiveness of round-robin depends on The number of jobs, and The size of the time quantum.
Large # of jobs means that the time between scheduling of a single job increases
Slow responses Larger time quantum means that the time
between the scheduling of a single job also increases
Slow responses Smaller time quantum means higher processing
rates but also more overhead!
![Page 102: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/102.jpg)
5: CPU-Scheduling 102
MULTI-LEVEL QUEUES:
Each queue has its scheduling algorithm. Then some other algorithm (perhaps priority
based) arbitrates between queues. Can use feedback to move between queues Method is complex but flexible. For example, could separate system processes,
interactive, batch, favored, unfavored processes
MULTI-LEVEL QUEUES
![Page 103: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/103.jpg)
Multilevel Queue Ready queue is partitioned into separate
queues:foreground (interactive)background (batch)
Each queue has its own scheduling algorithm foreground – RR background – FCFS
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
![Page 104: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/104.jpg)
Multilevel Queue Scheduling
![Page 105: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/105.jpg)
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
![Page 106: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/106.jpg)
Example of Multilevel Feedback Queue
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.
![Page 107: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/107.jpg)
Multilevel Feedback Queues
![Page 108: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/108.jpg)
OS/ProcSche/NI2008 108
Multi-Level Queue Scheduling
Multiple queues, each with its own priority. Equivalently: each priority has its own ready queue
Within each queue...Round-robin scheduling. Simplist Approach:
A Process’s priority is fixed & unchanging
CPU
High priority
Low priority
![Page 109: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/109.jpg)
OS/ProcSche/NI2008 109
Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive
Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities
Priorities are altered over time, as process behavior changes!
![Page 110: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/110.jpg)
OS/ProcSche/NI2008 110
Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive
Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities
Priorities are altered over time, as process behavior changes!
Issue: When do you change the priority of a process and how often?
![Page 111: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/111.jpg)
OS/ProcSche/NI2008 111
Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive
Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities
Priorities are altered over time, as process behavior changes!
Issue: When do you change the priority of a process and how often?
Solution: Let the amount of CPU used be an indication of how a process is to be handled
Expired time quantum more processing needed Unexpired time quantum less processing needed
Adjusting quantum and frequency vs. adjusting priority?
![Page 112: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/112.jpg)
5: CPU-Scheduling 112
Here’s how the priorities are used in Windows
CPU SCHEDULING Using Priorities
![Page 113: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/113.jpg)
OS/ProcSche/NI2008 113
Multi-Level Feedback Queue Scheduling n priority levels, round-robin scheduling within a
level Quanta increase as priority decreases Jobs are demoted to lower priorities if they do not
complete within the current quantum
CPU
High priority
Low priority
??
![Page 114: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/114.jpg)
OS/ProcSche/NI2008 114
Lottery Scheduling
Scheduler gives each thread some lottery tickets To select the next process to run...
The scheduler randomly selects a lottery number The winning process gets to run
Example Thread A gets 50 tickets Thread B gets 15 tickets Thread C gets 35 tickets There are 100 tickets outstanding.
![Page 115: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/115.jpg)
OS/ProcSche/NI2008 115
Lottery Scheduling
Scheduler gives each thread some lottery tickets. To select the next process to run...
The scheduler randomly selects a lottery number The winning process gets to run
Example Thread A gets 50 tickets 50% of CPUThread B gets 15 tickets 15% of CPUThread C gets 35 tickets 35% of CPUThere are 100 tickets outstanding.
![Page 116: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/116.jpg)
OS/ProcSche/NI2008 116
Lottery Scheduling
Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery
number The winning process gets to run Example Thread A gets 50 tickets 50% of CPU
Thread B gets 15 tickets 15% of CPUThread C gets 35 tickets 35% of CPUThere are 100 tickets outstanding.• Flexible• Fair• Responsive
![Page 117: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/117.jpg)
5: CPU-Scheduling 117
MULTIPLE PROCESSOR SCHEDULING:
Different rules for homogeneous or heterogeneous processors.
Load sharing in the distribution of work, such that all processors have an equal amount to do.
Each processor can schedule from a common ready queue ( equal machines ) OR can use a master slave arrangement.
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.
CPU SCHEDULING
![Page 118: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/118.jpg)
OS/ProcSche/NI2008 118
A Brief Look at Real-Time Systems
Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor
systems or multimedia data)
![Page 119: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/119.jpg)
OS/ProcSche/NI2008 119
A Brief Look at Real-Time Systems
Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor
systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers
Earliest-Deadline-First Schedulers
![Page 120: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/120.jpg)
OS/ProcSche/NI2008 120
A Brief Look at Real-Time Systems
Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor
systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers
Assign a fixed, unchanging priority to each process No dynamic adjustment of priorities
• Less aggressive allocation of processor Earliest-Deadline-First Schedulers
Assign dynamic priorities based upon deadlines
![Page 121: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/121.jpg)
OS/ProcSche/NI2008 121
A Brief Look at Real-Time Systems
Typically real-time systems involve several steps (that aren’t in traditional systems)
Admission control All processes must ask for resources ahead of time. If sufficient resources exist,the job is “admitted” into
the system. Resource allocation
Upon admission... the appropriate resources need to be reserved for
the task. Resource enforcement
Carry out the resource allocations properly
![Page 122: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/122.jpg)
OS/ProcSche/NI2008 122
Rate Monotonic Schedulers
For preemptable, periodic processes (tasks)
Assigns a fixed priority to each task T = The period of the task C = The amount of processing per task period
In RMS scheduling, the question to answer is... What priority should be assigned to a given task?
Process P1T = 1 secondC = 1/2 second / period
![Page 123: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/123.jpg)
OS/ProcSche/NI2008 123
Rate Monotonic Schedulers
P1
P2
![Page 124: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/124.jpg)
OS/ProcSche/NI2008 124
Rate Monotonic Schedulers
P1PRI > P2PRI
P2PRI > P1PRI
P1
P2
![Page 125: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/125.jpg)
OS/ProcSche/NI2008 125
Rate Monotonic Schedulers
P1PRI > P2PRI
P2PRI > P1PRI
P1
P2
The computation for P2 cannot be increased
![Page 126: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/126.jpg)
OS/ProcSche/NI2008 126
Rate Monotonic Schedulers
Assign shortest period tasks to the highest priorities
Admission control is difficult...< 69% There is a standard formula> 69% It may be possible, but need to do more
complex analysis
![Page 127: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/127.jpg)
OS/ProcSche/NI2008 127
Rate Monotonic Schedulers
Assumptions: Processes complete (yield) within their period Independent processes Same CPU requirements per burst Other non-periodic processes have no deadlines Instantaneous preemption with no overhead
![Page 128: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/128.jpg)
OS/ProcSche/NI2008 128
Earliest Deadline First
When processes do not need periodic executionor have constant CPU requirements...
When processes have deadline specifications...
Unlike RMS, EDF uses dynamic priorities (based upon earliest deadline first)(+) 100% processor utilization …?(-) Need to keep track of deadlines
Admission Control Just check to see if 100% processor utilization. Sum the Ci/Ti’s and see if less than or equal to 1 What about overhead?
![Page 129: Processor Scheduling](https://reader035.vdocuments.us/reader035/viewer/2022062521/568155dc550346895dc3a3de/html5/thumbnails/129.jpg)
OS/ProcSche/NI2008 129
Quiz
What are the main tasks of the scheduler? What is the difference between preemptive and non-
preemptive scheduling? What is the advantage of a shorter scheduling
quantum? What is the advantage of a longer scheduling quantum? Why is feedback scheduling useful for interactive jobs? Are these scheduling policies subject to starvation?
Shortest Job First scheduling? Round Robin scheduling? First Come First Served scheduling? Priority scheduling? Earliest Deadline First scheduling?