Week 5 - CPU Scheduling
Week 5 - CPU Scheduling
Scheduling
Engr. Cris Calitina
TOPICS
Scheduling
Basic Concepts Scheduling Criteria
Algorithms
Algorithm
Evaluation
Objectives
TO INTRODUCE CPU SCHEDULING, TO DESCRIBE VARIOUS CPU- TO DISCUSS EVALUATION CRITERIA TO EXAMINE THE SCHEDULING
WHICH IS THE BASIS FOR SCHEDULING ALGORITHMS FOR SELECTING A CPU-SCHEDULING ALGORITHMS OF SEVERAL
MULTIPROGRAMMED OPERATING ALGORITHM FOR A PARTICULAR OPERATING SYSTEMS
SYSTEMS SYSTEM
BASIC CONCEPTS
• Maximum CPU utilization obtained with
multiprogramming
• CPU–I/O Burst Cycle – Process execution
consists of a cycle of CPU execution and I/O
wait
• CPU burst followed by I/O burst
• CPU burst distribution is of main concern
CPU
Scheduler
Short-term scheduler
selects from among
the processes in
ready queue, and
allocates the CPU to
one of them
CPU scheduling decisions may take place when a process:
Terminates
P2 P3 P1
0 3 6 30
0 3 9 16 24
• Commonly, α set to ½
• Preemptive version called shortest-remaining-time-first
Prediction of the Length of the Next CPU Burst
Examples of Exponential Averaging
• =0
• n+1 = n
• Recent history does not count
• =1
• n+1 = tn
• Only the actual last CPU burst counts
• If we expand the formula, we get:
n+1 = tn+(1 - ) tn -1 + …
+(1 - )j tn -j + …
+(1 - )n +1 0
P1 P2 P4 P1 P3
0 1 5 10 17 26
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
• Conflict phase of
dispatch latency:
1.Preemption of
any process
running in
kernel mode
2.Release by low-
priority process
of resources
needed by high-
priority
processes
Priority-based Scheduling
• For real-time scheduling, scheduler must support
preemptive, priority-based scheduling
• But only guarantees soft real-time
• Linux scheduling
• Windows scheduling
• Solaris scheduling
Linux Scheduling Through Version 2.5
RR is 23ms:
Queueing Models
• Describes the arrival of processes, and CPU
and I/O bursts probabilistically
• Commonly exponential, and described by mean
• Computes average throughput, utilization, waiting
time, etc
• Computer system described as network of
servers, each with queue of waiting processes
• Knowing arrival rates and service rates
• Computes utilization, average queue length,
average wait time, etc
Little’s Formula
• n = average queue length
• W = average waiting time in queue
• λ = average arrival rate into queue
• Little’s law – in steady state, processes leaving
queue must equal processes arriving, thus:
n=λxW
• Valid for any scheduling algorithm and arrival
distribution
• For example, if on average 7 processes arrive per
second, and normally 14 processes in queue, then
average wait time per process = 2 seconds
Simulations
• Queueing models limited
• Simulations more accurate
• Programmed model of computer system
• Clock is a variable
• Gather statistics indicating algorithm performance
• Data to drive simulation gathered via
• Random number generator according to probabilities
• Distributions defined mathematically or empirically
• Trace tapes record sequences of real events in real systems
Evaluation of CPU Schedulers by Simulation
Implementation
Even simulations have limited accuracy
Just implement new scheduler and test in real
systems
High cost, high risk
Environments vary
Most flexible schedulers can be modified per-site or
per-system
Or APIs to modify priorities
But again environments vary