Project 3
description
Transcript of Project 3
![Page 1: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/1.jpg)
1
Project 3
Part 1: The Sleeping Barber problem Use semaphores and mutex variables for thread
synchronization You decide how to test your code!!
• We’re not providing the sample output for this one!
Part 2: The Gaming Parlor problem Use monitors and condition variables for
synchronization Avoid deadlock when handling resource requests Sample output given in handout
![Page 2: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/2.jpg)
2
CS 333Introduction to Operating Systems
Class 8 - Scheduling
Jonathan WalpoleComputer Science
Portland State University
![Page 3: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/3.jpg)
3
Process state model
New ProcessReady
Blocked
RunningTermination
![Page 4: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/4.jpg)
4
CPU scheduling criteria
CPU Utilization – how busy is the CPU?
Throughput – how many jobs finished/unit time?
Turnaround Time – how long from job submission to job termination?
Response Time – how long (on average) does it take to get a “response” from a “stimulus”?
Missed deadlines – were any deadlines missed?
![Page 5: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/5.jpg)
5
Scheduler options
Priorities May use priorities to determine who runs
next 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 6: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/6.jpg)
6
Scheduling policies
First-Come, First Served (FIFO) Shortest Job First (non-preemptive) Shortest Job First (with preemption) Round-Robin Scheduling Priority Scheduling Real-Time Scheduling
![Page 7: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/7.jpg)
7
First-Come, First-Served (FIFO)
Start jobs in the order they arrive (FIFO queue) Run each job until completion
![Page 8: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/8.jpg)
8
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 9: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/9.jpg)
9
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 10: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/10.jpg)
10
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 11: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/11.jpg)
11
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 12: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/12.jpg)
12
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 13: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/13.jpg)
13
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 14: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/14.jpg)
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
![Page 15: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/15.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/16.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/17.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/18.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/19.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/20.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/21.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/22.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/23.jpg)
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 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 24: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/24.jpg)
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 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 25: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/25.jpg)
25
Shortest Job First
Select the job with the shortest (expected) running time Non-Preemptive
![Page 26: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/26.jpg)
26
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 27: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/27.jpg)
27
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 28: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/28.jpg)
28
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 29: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/29.jpg)
29
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 30: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/30.jpg)
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
![Page 31: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/31.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/32.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/33.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/34.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/35.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/36.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/37.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/38.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/39.jpg)
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 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1
![Page 40: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/40.jpg)
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 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3
![Page 41: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/41.jpg)
41
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 42: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/42.jpg)
42
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 43: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/43.jpg)
43
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 44: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/44.jpg)
44
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 45: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/45.jpg)
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
![Page 46: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/46.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/47.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/48.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/49.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/50.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/51.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/52.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/53.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/54.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/55.jpg)
55
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 56: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/56.jpg)
56
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 57: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/57.jpg)
57
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 58: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/58.jpg)
58
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 59: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/59.jpg)
59
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 60: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/60.jpg)
60
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 61: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/61.jpg)
61
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 62: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/62.jpg)
62
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 63: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/63.jpg)
63
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 64: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/64.jpg)
64
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 65: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/65.jpg)
65
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 66: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/66.jpg)
66
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 67: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/67.jpg)
67
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 68: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/68.jpg)
68
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 69: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/69.jpg)
69
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 70: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/70.jpg)
70
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 71: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/71.jpg)
71
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 72: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/72.jpg)
72
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 73: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/73.jpg)
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
Ready List:
![Page 74: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/74.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/75.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/76.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/77.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/78.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/79.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/80.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/81.jpg)
81
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 82: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/82.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/83.jpg)
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: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/84.jpg)
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
![Page 85: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/85.jpg)
85
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 86: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/86.jpg)
86
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 87: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/87.jpg)
87
Scheduling in general purpose systems
![Page 88: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/88.jpg)
88
Priority scheduling
Assign a priority (number) to each process Schedule processes based on their priority Higher priority 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 89: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/89.jpg)
89
Multi-Level Queue Scheduling
Multiple queues, each with its own priority. Equivalently: each priority level 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 90: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/90.jpg)
90
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 91: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/91.jpg)
91
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 92: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/92.jpg)
92
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 93: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/93.jpg)
93
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 94: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/94.jpg)
94
Multi-Level Feedback Queue Scheduling
Details, details, details... Starting priority? Frequency of moving between priorities? How long should the time quantum be?
![Page 95: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/95.jpg)
95
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 96: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/96.jpg)
96
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 CPU
Thread C gets 35 tickets 35% of CPU
There are 100 tickets outstanding.
![Page 97: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/97.jpg)
97
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 98: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/98.jpg)
98
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 99: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/99.jpg)
99
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) Allows for specification of requirements
![Page 100: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/100.jpg)
100
A Brief Look at Real-Time Systems
Two main types of schedulers...
Rate-Monotonic Schedulers Assign a fixed, unchanging priority to each process
based on its requirements specification No dynamic adjustment of priorities
Earliest-Deadline-First Schedulers Assign dynamic priorities based upon deadlines
![Page 101: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/101.jpg)
101
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 P1
T = 1 secondC = 1/2 second / period
![Page 102: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/102.jpg)
102
Rate Monotonic Schedulers
P1
P2
![Page 103: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/103.jpg)
103
Rate Monotonic Schedulers
P1PRI > P2PRI
P2PRI > P1PRI
P1
P2
![Page 104: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/104.jpg)
104
Rate Monotonic Schedulers
P1PRI > P2PRI
P2PRI > P1PRI
P1
P2
Which is best?
![Page 105: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/105.jpg)
105
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 106: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/106.jpg)
106
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 107: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/107.jpg)
107
Earliest Deadline First
When processes do not have periodic executionor 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 108: Project 3](https://reader034.fdocuments.net/reader034/viewer/2022042519/56813a64550346895da25bd7/html5/thumbnails/108.jpg)
108
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?