Professional Documents
Culture Documents
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
Scheduling in BSD UNIX
Fred Kuhns ( )
Basic Concepts
Maximum CPU utilization obtained with
multiprogramming
CPUI/O Burst Cycle Process
execution consists of a cycle of CPU
execution and I/O wait.
CPU burst distribution
Fred Kuhns ( )
Fred Kuhns ( )
Fred Kuhns ( )
CPU Scheduler
Selects from the Ready processes in memory
CPU scheduling decisions occur when process:
1. Switches from running to waiting state.
2.Switches from running to ready state.
3.Switches from waiting to ready.
4.Terminates.
Fred Kuhns ( )
Dispatcher
Dispatcher module gives control of the
CPU to the process selected by the
short-term scheduler; this involves:
switching context
switching to user mode
jumping to the proper location in the user
program to restart that program
Scheduling Criteria
CPU utilization Percent time CPU busy
Throughput # of processes that
complete their execution per time unit
Turnaround time time to execute a
process: from start to completion.
Waiting time time in Ready queue
Response time amount of time it takes
from when a request was submitted until
the first response is produced, not output
(for time-sharing environment)
Fred Kuhns ( )
Optimization Criteria
Fred Kuhns ( )
Example:
P2
24
P3
27
30
P3
3
P1
6
30
10
11
P3
7
Burst Time
P2
8
P4
12
16
Fred Kuhns ( )
12
Process
P1 0.0
P2 2.0
P3 4.0
P4 5.0
Arrival Time
7
4
1
4
SJF (preemptive)
P1
P2
P3
P2
Burst Time
P4
7
P1
11
16
Fred Kuhns ( )
13
14
n+1 = n
Recent history does not count.
=1
n+1 = tn
Only the actual last CPU burst counts.
15
Priority Scheduling
Priority associated with each process
CPU allocated to process with highest priority
Preemptive or non-preemptive
Example - SJF: priority scheduling where priority
is predicted next CPU burst time.
Problem: Starvation
low priority processes may never execute.
Solution: Aging
as time progresses increase the priority of
the process.
Fred Kuhns ( )
16
q large FIFO
q small q must be large with respect to
context switch, otherwise overhead too high.
Fred Kuhns ( )
17
P2
20
37
P3
P4
57
P1
77
P3
P4
P1
P3
P3
18
Small Quantum
Increased Context Switches
Fred Kuhns ( )
19
Fred Kuhns ( )
20
Multilevel Queue
Ready queue partitioned into separate
queues:
foreground (interactive) and background (batch)
21
Fred Kuhns ( )
22
number of queues
scheduling algorithms for each queue
method used to select when upgrade process
method used to select when demote process
method used to determine which queue a process
will enter when that process needs service
Fred Kuhns ( )
23
Fred Kuhns ( )
24
Scheduling
Fred Kuhns ( )
25