- The success of CPU scheduling depends on an observed property of processes:
- Process execution consists of a cycle of CPU execution and I/O wait. Processes alternate between these two states.
- Process execution begins with a CPU burst. That is followed by an I/O burst, which is followed by another CPU burst, then
another I/O burst, and so on.
- Eventually, the final CPU burst ends with a system request to terminate execution (see Fig. 5.1).
Alternating sequence of CPU and I/O bursts.
- The durations of CPU bursts have been measured extensively. They tend to have a frequency curve similar to that shown in Fig. 5.2.
Histogram of CPU-burst durations.
- The curve is generally characterized as exponential or hyperexponential, with a large number of short CPU bursts and a small number of long CPU bursts.
- An I/O-bound program typically has many short CPU bursts.
- A CPU-bound program might have a few long CPU bursts.
- This distribution can be important in the selection of an appropriate CPU-scheduling algorithm.
- Nearly all processes alternate bursts of computing with (disk) I/O requests, as shown in Fig. 5.3.
Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process.
- Some processes, such as the one in Fig. 5.3a, spend most of their time computing (CPU-bound), while others, such as the one in Fig. 5.3b, spend most of their time waiting for I/O (I/O-bound).
- Having some CPU-bound processes and some I/O-bound processes in memory together is a better idea than first loading and running all the CPU-bound jobs and then when they are finished loading and running all the I/O-bound jobs (a careful mix of processes).