CPU Scheduling

As we learned in the previous topics, when a process is running on a CPU for a while, it might block (move into waiting state) for I/O, interrupt, or other event that temporarily prevents it from running currently on the CPU.

While the process is blocking, if we keep the CPU idle (that is, doing essentially nothing,) we will be wasting precious time that would be otherwise spent on running other, ready programs.

To prevent a CPU from sitting idle, the CPU scheduler, which is software that is a part of the OS, is responsible for deciding how and when processes will receive the CPU to run thereon.

The major challenge of the scheduler is to make the usage of the CPU as efficient as possible (we will explain what "efficient" could mean when we speak about Scheduling Criteria) and as fair as possible. These two terms are usually some subjective priorities that the developers of the OS wish the scheduler to exercise.