View
231
Download
2
Tags:
Embed Size (px)
Citation preview
Uniprocessor Scheduling I
Chapter 9
Goals of Scheduling
Quick response timeFast throughputProcessor efficiency
Type of Scheduling (1)
Long-term performed when new process is created The decision to add to the pool of processes
to be executed (chapter 3, process control)Medium-term
swapping The decision to add to the number of
processes that are partially or fully in main memory (chapter 7 and 8, control structure)
Types of Scheduling
Short-term which ready process to execute next decision as to which ready process will be
executed by the processor (chatter 9 and 10)
I/O decision as to which process’s pending
I/O request shall be handled by available I/O device (chapter 11)
Scheduling and Process State Transition
ExitRunningReady
BlockedBlocked,suspend
Ready,suspend
New
Long-termscheduling
Medium-termscheduling
Medium-termscheduling
Long-termscheduling
Short-termscheduling
A Seven-State Model - States
Ready: The process is in main memory and available for execution.
Blocked: The process is in main memory and awaiting an event.
Blocked, suspend: The process is in secondary memory and awaiting an event.
Ready, suspend: The process is in secondary memory but is available for execution as soon as it is loaded into main memory.
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
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
Medium-Term Scheduling
SwappingBased on the need to manage
multiprogramming
Short-Term Scheduling
Known as the dispatcherInvoked when an event occurs
clock interrupts I/O interrupts operating system calls signals
Short-Tem Scheduling Criteria
User-oriented Related to the behavior of the system as
perceived by the individual user or process. Response Time: Elapsed time between the
submission of a request until there is output.
System-oriented The focus if on effective and efficient
utilization of the processor
Short-Term Scheduling CriteriaPerformance-related
Performance-related criteria are quantitative and generally can be readily measured.
measurable such as response time and throughput
Not performance related predictability: a given job should run in
about the same amount of time and at about the same cost regardless of the load on the system
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
Priority Queuing
Processor
Eventoccurs Blocked Queue
Event Wait
Preemption
Admit
RQn
RQ1
RQ0Dispatch
Release
.
.
.
Priority
[RQi] >[RQj]
for i<j
A set of queues to instead of a single ready queue
Decision Mode
Nonpreemptive Once a process is in the running state, it will
continue until it terminates or blocks itself for I/OPreemptive
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
An Example for Scheduling Policies
Process Arrival Time Service Time
1
2
3
4
5
0
2
46
8
3
6
4
5
2
Each process joins the Ready queueWhen 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)
Turnaround Time and Service Time
Turnaround Time Tq - the total time that the item
spends in the system (waiting time plus service time,
or finish time mines arrival time).
Service Time Ts - Finish Time minus Start Time.
Normalized Turnaround Time - the ratio of turnaround
time to service time
Tq / Ts
FCFS -Normalized Turnaround Time
Process Arrival Serve Start Finish Turnaround Tq/Ts
Time Time Ts Time Time Time Tq
A 0 1 0 1 1 1
B 1 100 1 101 100 1
C 2 1 101 102 100 100
D 3 100 102 202 199 1.99
Mean 100 26
Difficulties with First-Come-First-Served
A short process may have to wait a very long time before it can execute
Favors CPU-bound processes CPU-bound processes: the processes
mostly use processor. I/O processes have to wait until CPU-
bound process completes
Uses preemption based on a clockAn amount of time is determined that
allows each process to use the processor for that length of time
Next ready job is selected.
Round-Robin q=1
0 5 10 15 20
1
2
3
4
5
02
23
45
66
7
88
910
1112
1314
16
Ready Time
Round-Robin q=4
0 5 10 15 20
1
2
3
4
5
24
6
P2 rest part ready time is 7
P4 rest part ready time is 15
P5 ready time is 8
P4 rest part ready time is 15
P5 ready time is 8
07
158
Ready Time
Ready Time