CS 3733 Operating Systems
Lecture 26 [3/13/98]: Process Scheduling
Reading: Sections 5.1-5.2 of SG
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
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
Process state diagrams for represention:
- How does the process traverse the diagram during a CPU burst cycle?
- What happens when an interrupt occurs?
- What happens when a signal is delivered?
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 = total time spent in ready queues.
- Response Time = Time between submission of a request to the first response.
- Response Time Variance
Skill: Understand how to represent the actions of scheduling by the
state diagram.
Revised 3/10/98