Академический Документы
Профессиональный Документы
Культура Документы
6.2
Objectives
To introduce CPU scheduling, which is the basis for
6.3
Basic Concepts
Maximum CPU utilization
concern
6.4
6.5
CPU Scheduler
Short-term scheduler selects from among the processes in
Terminates
6.6
6.7
Dispatcher
Dispatcher module gives control of the CPU to the process
switching context
6.8
Scheduling Criteria
CPU utilization keep the CPU as busy as possible
Throughput # of processes that complete their execution per
time unit
process
ready queue
was submitted until the first response is produced, not output (for
time-sharing environment)
6.9
6.10
Burst Time
P1
24
P2
P3
24
P3
2
27
30
6.11
P
0
P1
30
6.12
set of processes
6.13
Example of SJF
ProcessArrival Time
P1 0.0
P2 2.0
P3 4.0
P4 5.0
Burst Time
P
0
4
3
P3
1
9
P2
16
24
6.14
Example of Shortest-remaining-time-first
Now we add the concepts of varying arrival times and preemption to
the analysis
Burst Time
P1
P2
P3
P4
P
0
P4
P1
10
P3
17
26
6.15
Priority Scheduling
A priority number (integer) is associated with each process
The CPU is allocated to the process with the highest priority
Preemptive
Nonpreemptive
process
6.16
Priority
P1
10
P2
P3
P4
P5
P1
P2
0
P2
P5
P1
6
P3
16
P4
18
19
6.17
If there are n processes in the ready queue and the time quantum
q large FIFO
6.18
Burst Time
P1
24
P2
P3
3
10
1
14
1
18
1
22
P1
1
26
30
6.19
6.20
6.21
Multilevel Queue
Ready queue is partitioned into separate queues, eg:
foreground (interactive)
background (batch)
foreground RR
background FCFS
6.22
6.23
parameters:
number of queues
6.24
Q2 FCFS
Scheduling
6.25
Multi-Processor/Core
scheduling
6.26
Multiple-Processor Scheduling
CPU scheduling more complex when multiple CPUs are
available
the system data structures, alleviating the need for data sharing
it is currently running
soft affinity
hard affinity
6.27
6.28
processor
6.29
Multicore Processors
Recent trend to place multiple processor cores on same
physical chip
6.30
6.31
6.32
Scheduling for
Real Time Systems
6.33
performance
1.
2.
6.34
dispatch latency:
1.
Preemption of
any process
running in kernel
mode
2.
6.35
Priority-based Scheduling
For real-time scheduling, scheduler must support preemptive, priority-
based scheduling
constant intervals
0tdp
6.36
CPU(s)
6.37
6.38
6.39
6.40
processor time
6.41
int *policy)
2. pthread_attr_setsched_policy(pthread_attr_t *attr,
int policy)
6.42
6.43
6.44
6.45
scheduling algorithm
Map into global priority with numerically lower values indicating higher
priority
If no time left (expired), not run-able until all other tasks use their slices
6.46
Scheduling classes
Rather than quantum based on fixed time allotments, based on proportion of CPU
time
default
2.
real-time
Calculates target latency interval of time during which task should run at least
once
CFS scheduler maintains per task virtual run time in variable vruntime
Associated with decay factor based on priority of task lower priority is higher
decay rate
Normal default priority yields virtual run time = actual run time
To decide next task to run, scheduler picks task with lowest virtual run time
6.47
CFS Performance
6.48
6.49
6.50
Homework #5
Homework #5
6.16 (30 points) (Page 308)
6.17 (30 points) (Page 308/309)
6. 19 (10 points) (Page 309)
6.24 (10 point) (Page 310)
--Validate the turnaround time in slide 6-21
(20 points)
Due: 3/25/2016
6.51
End of Chapter 6
Windows Scheduling
Windows uses priority-based preemptive scheduling
Highest-priority thread runs next
Dispatcher is scheduler
Thread runs until (1) blocks, (2) uses time slice, (3)
6.53
Win32 API identifies several priority classes to which a process can belong
REALTIME_PRIORITY_CLASS, HIGH_PRIORITY_CLASS,
ABOVE_NORMAL_PRIORITY_CLASS,NORMAL_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS, IDLE_PRIORITY_CLASS
6.54
6.55
Windows Priorities
6.56
Solaris
Priority-based scheduling
Six classes available
Interactive (IA)
System (SYS)
6.57
6.58
Solaris Scheduling
6.59
priority
Runs until (1) blocks, (2) uses time slice, (3) preempted by
higher-priority thread
6.60
Algorithm Evaluation
How to select CPU-scheduling algorithm for an OS?
Determine criteria, then evaluate algorithms
Deterministic modeling
6.61
Deterministic Evaluation
For each algorithm, calculate minimum average waiting time
Simple and fast, but requires exact numbers for input, applies only to
those inputs
FCS is 28ms:
RR is 23ms:
6.62
Queueing Models
Describes the arrival of processes, and CPU and I/O bursts
probabilistically
6.63
Littles Formula
n = average queue length
W = average waiting time in queue
= average arrival rate into queue
Littles law in steady state, processes leaving queue must equal
6.64
Simulations
Queueing models limited
Simulations more accurate
Clock is a variable
6.65
6.66
Implementation
Environments vary
6.67
Thread Scheduling
Distinction between user-level and kernel-level threads
When threads supported, threads scheduled, not processes
Many-to-one and many-to-many models, thread library schedules user-
6.68
Pthread Scheduling
API allows specifying either PCS or SCS during thread creation
PTHREAD_SCOPE_SYSTEM
6.69
6.70
6.71