CS 3733 Operating Systems
Lecture 24 [11/17/97]: Process Scheduling
Reading: Tanenbaum 2.4
Scheduling overview:
- States of a process:
- new
- running - using CPU
- ready - in memory, ready for the CPU
- waiting - waiting for an I/O device or interrupt
- done
- State diagrams:
- A circle represents each state.
- An arc from state A to state B represents
a transition caused by an event
- Each arc should be labeled.
- Each state is represented by a queue or equivalent data structure
- The job queue --- All processes in mass storage waiting for
allocation to main memory.
- The ready queue --- All processes in main memory waiting for the
CPU. Usually a linked list of PCB's (process control blocks) with pointers
to the first and last PCBs.
- Several device queues --- One for each device containing all
processes waiting for a particular device. These are mainly disk drives
- Types of Schedulers
- Long-term scheduler or job scheduler
decides which processes are admitted to the
system.
- Medium-term scheduler does swapping --- moving processes in and out
of memory.
- Short-term scheduler or CPU scheduler decides which process is
selected from the ready queue(s).
Short-term scheduling terminology
- A process consists of a cycle of CPU bursts and I/O bursts.
- Short-term scheduler must make a decision when a process:
- switches from running to waiting --- say for I/O
- switches from running to ready --- because of an interrupt
- switches from waiting to ready --- I/O has completed
- Non-preemptive scheduling:
Once a process has the CPU, it keeps it until it needs I/O or is finished.
- Preemptive scheduling: a higher priority process may be selected when
the OS gets in because of an interrupt or other event.
- Context switch --- Switching the CPU to another process requires saving
the state of the old process and loading the saved state of the new process.
- Dispatcher --- The module that gives control of the CPU to the
process selected by the CPU scheduler. It does:
- context switching
- switching to user mode
- setting to program counter
- Performance criteria for CPU schedulers
- Fairness
- Efficiency = CPU Utilization
- Throughput = number of processes completed per unit time.
- Turnaround Time = Time to execute a process from submission to termination.
- Waiting Time
- Response Time = Time between submission of a request to the first response.
- Response Time Variance
Revision Date: 11/18/97