Scheduling
On a uniprocessor system there is only one process running, all others have to wait until they are scheduled. They are waiting in some scheduling queue:
Processes
Job Queue
Holds the future processes of the system.
Ready Queue (also called CPU queue)
Holds all processes that reside in memory and are ready to execute.
Device Queue (also called I/O queue)
Each device has a queue holding the processes waiting for I/O completion.
IPC Queue
Holds the processes that wait for some IPC (inter process communication) event to occur.
Computer Architecture
WS 06/07
Dr.-Ing. Stefan Freinatis
Scheduling
Processes
Ready queue
Tape
These queues are empty Device queues
Ethernet
registers registers registers
Disk
Terminal
registers
The ready queue and some device queues
Figure from [Sil00 p.92], modified
Computer Architecture
WS 06/07
Dr.-Ing. Stefan Freinatis
Scheduling
From the job queue a new process is initially put into the ready queue. It waits until it is dispatched (selected for execution). Once the process is allocated the CPU, one of these events may occur.
Processes
Interrupt
The time slice may be expired or some higher priority process is ready. Hardware error signals (exceptions) also may cause a process to be interrupted.
I/O request
The process requests I/O. The process is shifted to a device queue. After the I/O device has ready, the process is put into the ready queue to continue.
IPC request
The process wants to comunicate with another process through some blocking IPC feature. Like I/O, but here the I/O-device is another process.
A note on the terminology: Strictly spoken, a process (in the sense of an active entity) only exists when it is allocated the CPU. In all other cases it is a dead body.
Computer Architecture WS 06/07 Dr.-Ing. Stefan Freinatis
Scheduling
Processes processes are ready process is running
Job queue
Ready queue
CPU
Interrupt I/O request events IPC request
processes are new
Device queue
processes are waiting
IPC queue
Queueing diagram of process scheduling
Computer Architecture WS 06/07 Dr.-Ing. Stefan Freinatis
Scheduling
The OS selects processes from queues and puts them into other queues. This selection task is done by schedulers.
Processes
Long-term Scheduler
Originates from batch systems. Selects jobs (programs) from the pool and loads them into memory. Invoked rather infrequently (seconds ... minutes). Can be slow. Has influence on the degree of multiprogramming (number of processes in memory). Some modern OS do not have a long-term scheduler any more.
Short-term Scheduler
Selects one process from among the processes that are ready to execute, and allocates the CPU to it. Initiates the context switches. Invoked very frequently (in the range of milliseconds). Must be fast, that is, must not consume much CPU time compared to the processes.
Computer Architecture WS 06/07 Dr.-Ing. Stefan Freinatis
Scheduling
Processes
Long-term scheduler
Short-term scheduler
Job queue
Ready queue
CPU
Schedulers and their queues
Computer Architecture WS 06/07 Dr.-Ing. Stefan Freinatis
Scheduling
Sometimes it may be advantageous to remove processes temporarily from memory in order to reduce the degree of multiprogramming. At some later time the process is reintroduced into memory and can be continued. This scheme is called swapping, performed by a medium-term scheduler.
Job queue
Processes
Ready queue
swap out
CPU
Medium-term scheduler
swap in
swap queue
Computer Architecture
WS 06/07
Dr.-Ing. Stefan Freinatis
Process Concept
Program in execution
Several processes may be carried out in parallel. Processes
Resource grouping
Each process is related to a certain task and groups together the required resources (Address space, PCB).
Traditional multi-processing systems:
Each process is executed sequentially
No parallelism inside a process.
Blocked operations Blocked process
Any blocking operation (e.g. I/O, IPC) blocks the process. The process must wait until the operation finishes.
In traditional systems each process has a single thread of control.
Computer Architecture WS 06/07 Dr.-Ing. Stefan Freinatis
Process Management