Uniprocessor Scheduling
description
Transcript of Uniprocessor Scheduling
![Page 1: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/1.jpg)
Chapter 9 1
Uniprocessor Scheduling
Chapter 9
![Page 2: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/2.jpg)
Chapter 9 2 of 26
Goals of Scheduling
• Quick response time• Fast throughput• Processor efficiency
![Page 3: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/3.jpg)
Chapter 9 3 of 26
Type of Scheduling
• Long-term• performed when new process is created
• Medium-term• swapping
• Short-term• which ready process to execute next
![Page 4: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/4.jpg)
Chapter 9 4 of 26
Types of Scheduling
• Short-term• decision as to which ready process will
be executed by the processor
• I/O • decision as to which process’s pending
I/O request shall be handled by available I/O device
![Page 5: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/5.jpg)
Chapter 9 5 of 26
Scheduling and Process State Transition
ExitRunningReady
BlockedBlocked,suspend
Ready,suspend
New
Long-termscheduling
Medium-termscheduling
Medium-termscheduling
Long-termscheduling
Short-termscheduling
![Page 6: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/6.jpg)
Chapter 9 6 of 26
Queuing Diagram for Scheduling
Processor
Medium-termscheduling
Medium-termscheduling
Batchjobs
Long-termscheduling
Time-out
Interactiveusers
Ready Queue
Ready, Suspend Queue
Blocked, Suspend Queue
Blocked QueueEvent
Occurs
Event Wait
ReleaseShort-termscheduling
![Page 7: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/7.jpg)
Chapter 9 7 of 26
Long-Term Scheduling
• Determines which programs are admitted to the system for processing
• Controls the degree of multiprogramming
• More processes, smaller percentage of time each process is executed
![Page 8: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/8.jpg)
Chapter 9 8 of 26
Medium-Term Scheduling
• Swapping• Based on the need to manage
multiprogramming
![Page 9: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/9.jpg)
Chapter 9 9 of 26
Short-Term Scheduling
• Known as the dispatcher• Invoked when an event occurs
• clock interrupts• I/O interrupts• operating system calls• signals
![Page 10: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/10.jpg)
Chapter 9 10 of 26
Short-Tem Scheduling Criteria
• User-oriented• Response Time
• Elapsed time between the submission of a request until there is output.
• System-oriented• effective and efficient utilization of the
processor
![Page 11: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/11.jpg)
Chapter 9 11 of 26
Short-Term Scheduling Criteria
• Performance-related• measurable such as response time and
throughput
• Not performance related• predictability
![Page 12: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/12.jpg)
Chapter 9 12 of 26
Priorities
• Scheduler will always choose a process of higher priority over one of lower priority
• Have multiple ready queues to represent each level of priority
• Lower-priority may suffer starvation• allow a process to change its priority
based on its age or execution history
![Page 13: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/13.jpg)
Chapter 9 13 of 26
Priority Queuing
Processor
Eventoccurs Blocked Queue
Event Wait
Preemption
Admit
RQn
RQ1
RQ0Dispatch
Release
.
.
.
![Page 14: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/14.jpg)
Chapter 9 14 of 26
Decision Mode
• Nonpreemptive• Once a process is in the running state, it will
continue until it terminates or blocks itself for I/O
• Preemptive• Currently running process may be interrupted
and moved to the Ready state by the operating system
• Allows for better service since any one process cannot monopolize the processor for very long
![Page 15: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/15.jpg)
Chapter 9 15 of 26
An Example
ProcessArrivalTime
ServiceTime
1
2
3
4
5
0
2
4
6
8
3
6
4
5
2
![Page 16: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/16.jpg)
Chapter 9 16 of 26
• Each process joins the Ready queue• When the current process ceases to
execute, the oldest process in the Ready queue is selected
0 5 10 15 20
1
2
3
4
5
First-Come-First-Served(FCFS)
![Page 17: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/17.jpg)
Chapter 9 17 of 26
First-Come-First-Served(FCFS)
• A short process may have to wait a very long time before it can execute
• Favors CPU-bound processes• I/O processes have to wait until CPU-
bound process completes
![Page 18: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/18.jpg)
Chapter 9 18 of 26
• Uses preemption based on a clock• An amount of time is determined that
allows each process to use the processor for that length of time
Round-Robin
0 5 10 15 20
1
2
3
4
5
![Page 19: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/19.jpg)
Chapter 9 19 of 26
Shortest Process Next
• Nonpreemptive policy• Process with shortest expected processing
time is selected next• Short process jumps ahead of longer
processes
0 5 10 15 20
1
2
3
4
5
![Page 20: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/20.jpg)
Chapter 9 20 of 26
Shortest Process Next
• Predictability of longer processes is reduced
• If estimated time for process not correct, the operating system may abort it
• Possibility of starvation for longer processes
![Page 21: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/21.jpg)
Chapter 9 21 of 26
Shortest Remaining Time
• Preemptive version of shortest process next policy
• Must estimate processing time
0 5 10 15 20
1
2
3
4
5
![Page 22: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/22.jpg)
Chapter 9 22 of 26
Highest Response Ratio Next (HRRN)
• Choose next process with the lowest ratio
time spent waiting + expected service timeexpected service time
1
2
3
4
5
0 5 10 15 20
![Page 23: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/23.jpg)
Chapter 9 23 of 26
Feedback
• Penalize jobs that have been running longer
• Don’t know remaining time process needs to execute
0 5 10 15 20
1
2
3
4
5
![Page 24: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/24.jpg)
Chapter 9 24 of 26
Fair 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 groups of processes
![Page 25: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/25.jpg)
Chapter 9 25 of 26
UNIX Scheduling
• Priorities are recomputed once per second
• Base priority divides all processes into fixed bands of priority levels
• Nice adjustment factor used to keep process in its assigned band
![Page 26: Uniprocessor Scheduling](https://reader035.fdocuments.net/reader035/viewer/2022062808/56815445550346895dc2523e/html5/thumbnails/26.jpg)
Chapter 9 26 of 26
Feedback
• Process is demoted to the next lower-priority queue each time it returns to the ready queue
• Longer processes drift downward• To avoid starvation, preemption time
for lower-priority processes is longer