uniprocessor scheduling
Post on 25-Jan-2016
43 Views
Preview:
DESCRIPTION
TRANSCRIPT
Chapter 9 1
Uniprocessor Scheduling
Chapter 9
Chapter 9 2 of 26
Goals of Scheduling
• Quick response time• Fast throughput• Processor efficiency
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
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
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
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
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
Chapter 9 8 of 26
Medium-Term Scheduling
• Swapping• Based on the need to manage
multiprogramming
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
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
Chapter 9 11 of 26
Short-Term Scheduling Criteria
• Performance-related• measurable such as response time and
throughput
• Not performance related• predictability
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
Chapter 9 13 of 26
Priority Queuing
Processor
Eventoccurs Blocked Queue
Event Wait
Preemption
Admit
RQn
RQ1
RQ0Dispatch
Release
.
.
.
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
Chapter 9 15 of 26
An Example
ProcessArrivalTime
ServiceTime
1
2
3
4
5
0
2
4
6
8
3
6
4
5
2
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)
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
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
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
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
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
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
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
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
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
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
top related