Lecture 4
Homework 1, Process Management Project
posted to course webpage
Outline
Round-robin (RR) scheduling Process management project Multi-level queue scheduling Multi-processor scheduling
Round-Robin (RR)
Round-robin (RR) scheduling can be thought
of as FCFS with preemption at fixed intervals.
As its name implies, each process gets some
CPU time in a round-robin manner, making it very good for time sharing OS's.
Define a time quantum (or time slice) q,
usually 10-100ms. The Ready Queue is FIFO. The currently running process gets up to 1
Round-Robin (RR)
Reconsider the first example from last time:
Process CPU burst time Arrival time
p1 24 0
p2 3 0
p3 3 0
with arrival order p1, p2, p3
Do wait time analysis with q = 4ms. Do again
Round-Robin (RR)
Wait time is bounded: (n-1)*q ms is maximum
wait time between each quantum. Actual performance depends on size of q.
One extreme: q =
=> FCFS Other extreme: q = 1ms, approaches
appearance of n processes each having its own processor that is 1/n as fast as the physical
Round-Robin (RR)
Making this all work requires hardware support.
In particular, context switches are costly. This tends to favor larger q sizes to reduce the
number of switches. E.g. for a process with burst size of 10 ms:
q = 12ms requires only one switch at the end
q = 6ms requires two switches
Round-Robin (RR)
Too large of q size approaches FCFS. Luckily,
recall distribution of burst sizes:
General rule is 80% of processes should finish
Process Management Project
Process management project is to simulate a
round-robin (RR) schedule with cascading
termination (i.e., when any process terminates, its children are terminated).
Simulation is parameterized by quantum size
(q) and an input file of actions.
Each action represents one time unit of
execution. A process may hold the CPU for up
to q time units, then a scheduling decision must
Multi-level Queue Scheduling (MQS)
The processes that do not finish in 1 quantum
may be very long as the chart indicates.
If we want to minimize the maximum wait time,
it might be better to give these processes more time the next time it gets the CPU.
Also, processes may have different processing
Multi-level Queue Scheduling (MQS)
For more flexibility, we can partition the Ready
Queue into separate queues each with a
different scheduling algorithm. Called
multi-level queue scheduling (MQS).
Example: foreground processes in one queue
using RR, background processes in another queue using FCFS.
Also must schedule between queues. Example:
Multi-level Queue Scheduling (MQS)
Example: different queues for different priority
processes. Could be absolute, preemptive. (highest)
→
System→
→
Interactive→
→
Interactive Editing→
Multi-level Feedback Queue
Scheduling (MFQS)
Another organization would be to allow
processes to move between queue levels.
Example:
admitted
→
q = 8→
→
q = 16→
Multi-level Feedback Queue
Scheduling (MFQS)
Processes start in first queue, then if do not
terminate, put on the second queue, etc. Usually preemptive.
Parameters for MQS and MFQS include
number of queues
schedule for each queue
when to put into lower queue
when to raise to higher queue, e.g. for aging
Multiprocessor Scheduling
Assume homogeneous hardware; any process
can run on any processor. Would like to share the load among processors. Two approaches:
Asymmetric multiprocessing: all scheduling is
done by one processor, the master server. Others only execute code given to them. System data
structures are not shared, simplifying system.
Symmetric multiprocessing (SMP): each
Multiprocessor Scheduling
Some issues in conflict in multiprocessor
scheduling
Processor affinity: once a process is running on a
processor, its data is already there, so we would like to keep the process running on the same
processor, if possible
Load balancing: try to keep utilization evenly
Multi-Core Processor Scheduling
Multi-core processors usually provide a limited
number of hardware threads that run on each core. To the OS, each hardware thread
appears as a logical processor. Example: UltraSPARC T1 CPU has 8 cores and 4 hardware threads per core giving an
appearance of 32 logical processors.
OS assigns a software thread to a hardware
How to Choose a Scheduling Algorithm?
Select criteria for evaluation and performance
measurement. For example,
Maximize CPU utilization while keeping maximum
response time under 1 second
Maximize throughput such that turnaround time is
How to Choose a Scheduling Algorithm?
Our method of evaluation is called
deterministic modeling, a form of analysis
that uses a synthetic workload to produce a formula or number for comparison.
This method is simple and fast to compute, but
not very realistic. Using real system traces can give more realistic numbers, but mostly this
How to Choose a Scheduling Algorithm?
Queuing models are a more mathematically
accurate evaluation method. Need to
determine the distribution of CPU and I/O
bursts as a probability function and an arrival (process creation) distribution.
Using queuing-network analysis can compute
utilization, average queue length, average wait time, etc.
Still need lots of simplifying assumptions to
How to Choose a Scheduling Algorithm?
Simulations can be used to evaluate
algorithms. Most interesting aspect is how to generate data to drive the simulation.
Random number generation in some probability
distribution (a la queuing models)
Trace tapes from actual systems
Some drawbacks: expensive, time-consuming,
How to Choose a Scheduling Algorithm?
Can evaluate a scheduling algorithm by
implementing it into an actual OS and taking actual measurements.