Professional Documents
Culture Documents
Chapter 5: CPU Scheduling: Silberschatz, Galvin and Gagne ©2009 Operating System Concepts - 8 Edition
Chapter 5: CPU Scheduling: Silberschatz, Galvin and Gagne ©2009 Operating System Concepts - 8 Edition
5.2
Objectives
To introduce CPU scheduling, which is the basis for multiprogrammed
operating systems
particular system
5.3
Basic Concepts
Maximum CPU utilization obtained with multiprogramming
CPUI/O Burst Cycle Process execution consists of a cycle of
5.4
5.5
5.6
CPU Scheduler
Selects from among the processes in memory that are ready to execute,
5.7
Dispatcher
Dispatcher module gives control of the CPU to the process selected
switching context
5.8
Scheduling Criteria
CPU utilization keep the CPU as busy as possible
Throughput # of processes that complete their execution per
time unit
ready queue
submitted until the first response is produced, not output (for timesharing environment)
5.9
5.10
Burst Time
P1
24
P2
P3
P1
P2
24
P3
27
30
5.11
P2
0
P3
3
P1
6
30
5.12
SJF is optimal gives minimum average waiting time for a given set of
processes
5.13
Example of SJF
Process
Arrival Time
Burst Time
P1
0.0
P2
2.0
P3
4.0
P4
5.0
P4
0
P3
P1
3
P2
16
24
5.14
averaging
5.15
5.16
n+1 = n
=1
n+1 = tn
Only the actual last CPU burst counts
n+1 = tn+(1 - ) tn -1 +
+(1 - )j tn -j +
+(1 - )n +1 0
Since both and (1 - ) are less than or equal to 1, each successive term
5.17
Priority Scheduling
A priority number (integer) is associated with each process
The CPU is allocated to the process with the highest priority (smallest
Preemptive
nonpreemptive
SJF is a priority scheduling where priority is the predicted next CPU burst
time
5.18
Performance
q large FIFO
5.19
Burst Time
P1
24
P2
P3
P1
0
P2
4
P3
7
P1
10
P1
14
P1
18 22
P1
26
P1
30
5.20
5.21
5.22
Multilevel Queue
Ready queue is partitioned into separate queues:
foreground (interactive)
background (batch)
foreground RR
background FCFS
Fixed priority scheduling; (i.e., serve all from foreground then from
background). Possibility of starvation.
Time slice each queue gets a certain amount of CPU time which it can
schedule amongst its processes; i.e., 80% to foreground in RR
5.23
5.24
parameters:
number of queues
5.25
Q2 FCFS
Scheduling
A new job enters queue Q0 which is served FCFS. When it gains CPU,
job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is
moved to queue Q1.
5.26
5.27
Thread Scheduling
Distinction between user-level and kernel-level threads
Many-to-one and many-to-many models, thread library schedules user-
5.28
Pthread Scheduling
API allows specifying either PCS or SCS during thread creation
5.29
5.30
5.31
Multiple-Processor Scheduling
CPU scheduling more complex when multiple CPUs are
available
soft affinity
hard affinity
5.32
5.33
Multicore Processors
Recent trend to place multiple processor cores on same physical chip
Faster and consume less power
Multiple threads per core also growing
5.34
5.35
5.36
5.37
Solaris Scheduling
5.38
Windows XP Priorities
5.39
Linux Scheduling
Constant order O(1) scheduling time
Two priority ranges: time-sharing and real-time
Real-time range from 0 to 99 and nice value from 100 to 140
(figure 5.15)
5.40
5.41
5.42
Algorithm Evaluation
Deterministic modeling takes a particular predetermined
Queueing models
Implementation
5.43
5.44
End of Chapter 5
5.08
5.46
In-5.7
5.47
In-5.8
5.48
In-5.9
5.49
Dispatch Latency
5.50
FIFO Queue is Used if There Are Multiple Threads With the Same Priority
5.51
2.
* Note the JVM Does Not Specify Whether Threads are Time-Sliced or Not
5.52
Time-Slicing
Since the JVM Doesnt Ensure Time-Slicing, the yield() Method
May Be Used:
while (true) {
// perform CPU-intensive task
...
Thread.yield();
}
This Yields Control to Another Thread of Equal Priority
5.53
Thread Priorities
Priority
Comment
Thread.MIN_PRIORITY
Thread.MAX_PRIORITY
Thread.NORM_PRIORITY
5.54
Solaris 2 Scheduling
5.55