Chapter 5: CPU Scheduling: 5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts With Java - 8 Edition
Chapter 5: CPU Scheduling: 5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts With Java - 8 Edition
5.1
5.2
Objectives
To introduce CPU scheduling, which is the
5.3
Basic Concepts
Maximum CPU utilization obtained with
multiprogramming
The
5.4
5.5
5.6
CPU Scheduler
Selects from among the processes in memory that are
process:
5.7
Dispatcher
Dispatcher module gives control of the CPU to
context
switching
to user mode
jumping
5.8
Scheduling Criteria
CPU utilization keep the CPU as busy as possible
Throughput # of processes that complete their
particular process
5.9
5.10
Burst Time
P1
24
P2
P3
P2
24
P3
27
30
5.11
P2
0
P3
3
P1
6
30
5.12
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
exponential averaging
n 1 t n 1 n
Most recent info
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
5.17
Priority Scheduling
A priority number (integer) is associated with each
process
never execute
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, 20% to background in FCFS
5.23
5.24
parameters:
number of queues
5.25
Q2 FCFS
Scheduling
5.26
5.27
Thread Scheduling
Distinction between user-level and kernel-level threads
Many-to-one and many-to-many models, thread library
5.28
Pthread Scheduling
API allows specifying either PCS or SCS during
thread creation
PTHREAD
PTHREAD
5.29
Multiple-Processor Scheduling
CPU scheduling more complex when multiple CPUs are available
Homogeneous processors within a multiprocessor
Asymmetric multiprocessing only one processor accesses the
currently running
soft affinity
hard affinity
5.30
5.31
Multicore Processors
Recent trend to place multiple processor cores on same physical chip
Faster and consume less power
Multiple threads per core also growing
Memory Stall
Operating System Concepts with Java 8th Edition
5.32
5.33
Solaris Scheduling
5.35
Windows XP Priorities
Priority classes
Relative
priority
5.36
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
5.37
5.38
All runnable tasks are stored in run queue which has two priority
arrays: active and expired.
The schedule chooses the task with highest priority from the
active array for execution.
The two priority arrays are exchanged when all tasks in active
arrays have exhausted their time slice.
Operating System Concepts with Java 8th Edition
5.39
Algorithm Evaluation
Deterministic modeling takes a particular predetermined
Queueing models.
Implementation
5.40
5.41
End of Chapter 5
5.42
5.08
5.43
In-5.7
5.44
In-5.8
5.45
In-5.9
5.46
Dispatch Latency
5.47
Algorithm
5.48
2.
* Note the JVM Does Not Specify Whether Threads are Time-Sliced or
Not
5.49
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.50
Thread Priorities
Priority
Comment
Thread.MIN_PRIORITY
Thread.MAX_PRIORITY
Thread.NORM_PRIORITY
5.51
Solaris 2 Scheduling
5.52
End of Chapter 5
5.53