2.3. The Process Scheduler¶
We define process scheduling as:
The act of determining which process in the ready state should be moved to the running state. That is, decide which process should run on the CPU next.
The goal of the scheduler:
Implement the virtual machine in such a way the user perceives that each process is running on it’s own computer.
Modern operating systems are generally able to achieve this because of the statistical properties of processes. Over a short period, processes can be categorized according to what is limiting the completion of the process.
- Processes that are mostly waiting for the completion of input or output (I/O) are I/O Bound.
- Interactive processes, such as office applications are mostly I/O bound the entire life of the process. Some processes may be I/O bound for only a few short periods of time.
- The expected short run time of I/O bound processes means that they will not stay the running the process for very long.
- They should be given high priority by the scheduler.
- CPU Bound processes are ones that are implementing algorithms with a large number of calculations.
- They can be expected to hold the CPU for as long as the scheduler will allow.
- Programs such as simulations may be CPU bound for most of the life of the process.
- Users do not typically expect an immediate response from the computer when running CPU bound programs.
- They should be given a lower priority by the scheduler.
Schedulers fall into one of two general categories:
when the currently executing process gives up the CPU voluntarily.
when the operating system decides to favor another process, preempting the currently executing process.
I was at work and trying to figure out how to make my heartbeat program run faster. And one of the senior engineers asked me if I thought that the program was CPU Bound or IO bound. At the time I had no idea what he meant by that so I did some research and here’s what I found out!
CPU Bound - CPU Standing for Central processing unit is the brains of the computer. This is where most of the calculations take place. Being CPU Bound means that a program would perform faster if the CPU was faster, and there for the upper limits are constrained by the CPU.
IO Bound - I/O stands for input output is used to describe the process of transferring data between the computer and a peripheral device. Every transfer is an output from one device and an input to another. Devices such as keyboards and mouses are input only devices. Being bound by your IO would be the upper limit rate at which your computer can process data between devices. An example would be the rate from which you read from disk by counting lines in a file or files on a disk.
It turns out my heartbeat program was IO bound because I was reading and writing to disk quite a bit of data. Yey for optimizations and learning how computers work.
For other answers check out the link below.