Professional Documents
Culture Documents
Chapter 3. Scheduling
Chapter 3. Scheduling
SCHEDULING
Who gets the CPU?
PROCESS BEHAVIOR
SCHEDULING
Processes alternate bursts of computing with I/O requests
CPU burst is the amount of time the process uses the
processor before it is no longer ready
The CPU runs for a while without stopping, then a system call is
made to read from a file or write to a file.
When the system call completes, the CPU computes again until it
needs more data or has to write more data
PROCESS BEHAVIOR
SCHEDULING
All systems
Fairness - giving each process a fair share of the CPU
Policy enforcement - seeing that stated policy is carried out
Balance - keeping all parts of the system busy
Batch systems
Throughput - maximize jobs per hour
Turnaround time - minimize time between submission and termination
CPU utilization - keep the CPU busy all the time
Interactive systems
Response time - respond to requests quickly
Proportionality - meet users’ expectations
Real-time systems
Meeting deadlines - avoid losing data
Predictability - avoid quality degradation in multimedia systems
SCHEDULING IN
SCHEDULING BATCH SYSTEMS
1. First-Come, First-Served
Processes are assigned the CPU in the order they request it
A single queue of ready jobs
Jobs are scheduled in order of arrival to ready queue
When the running process blocks, the first process on the
queue is run next
When a blocked process becomes ready, like a newly arrived
job, it is put on the end of the queue, behind all waiting
processes
FCFS EXAMPLE
SCHEDULING
31
P1 waiting time: 0
P2 waiting time: 6 The average waiting time (AWT):
P3 waiting time: 14 (0+6+14+21)/4 = 10.25
P4 waiting time: 21
SCHEDULING IN
SCHEDULING INTERACTIVE SYSTEMS
1. Round-Robin Scheduling
One of the oldest, simplest, most commonly used scheduling
algorithm
Select a process from ready queue in a round-robin fashion (take
turns)
Each process is assigned a time interval, called its quantum,
during which it is allowed to run
If the process is still running at the end of the quantum, the
CPU is preempted and given to another process
ROUND ROBIN EXAMPLE
SCHEDULING
2. Priority Scheduling
Not all processes are equally important
Each process is assigned a priority, and the runnable process with
the highest priority is allowed to run
On a PC with a single owner, there may be multiple processes,
some of them more important than others
For example, a daemon process sending electronic mail in the
background should be assigned a lower priority than a
process displaying a video on the screen in real time
SCHEDULING IN
SCHEDULING INTERACTIVE SYSTEMS
P1
P2
P3