Course contentsShow
← Computer Science
Lesson 1244 of 2,87229. CPU SchedulingFree lesson

Scheduling Decision Points

The four situations when scheduling decisions occur: process termination, blocking, creation, and interrupt handling.

Scheduling Decision Points

You'll learn when the operating system must make a CPU scheduling decision.

When Does the OS Need to Choose?

Imagine a busy restaurant kitchen where the head chef constantly decides which order to prepare next. The CPU scheduler faces a similar challenge: when should it stop and decide which process gets the processor? Not every microsecond—that would be wasteful. Instead, specific events naturally trigger these decisions.

The Four Key Decision Moments

The scheduler must act at four critical points:

1. Process Termination

When a running process calls exit() or finishes, the CPU is suddenly free. The scheduler must pick a new process from the ready queue immediately—the CPU can't sit idle.

2. Process Blocking

When a process performs I/O or calls wait(), it moves from running to waiting. It can't continue, so the scheduler must select another ready process. This is like a customer stepping away from the counter—next person, please!

3. Process Creation

When fork() creates a new process, the scheduler faces a choice: keep running the parent, or switch to the newly created child? Both are now ready to run.

4. Interrupt Handling

When an I/O device completes or a timer fires, an interrupt occurs. A waiting process might now be ready, or a time slice might have expired. The scheduler evaluates whether to continue the current process or switch.

Preemptive vs Non-Preemptive

Notice points 1 and 2 are unavoidable—the running process can't continue. Points 3 and 4 are choices: in non-preemptive scheduling, the current process keeps running. In preemptive scheduling, the OS can switch processes even when the current one could continue.

Key Takeaway: The OS scheduler makes decisions at four natural transition points: when processes terminate, block, are created, or when interrupts occur—balancing responsiveness with overhead.