Sobes.tech
Senior

What happens inside the scheduler during a blocking system call?

sobes.tech AI

Answer from AI

In a blocking system call, the OS scheduler suspends the execution of the current thread or process that is waiting for the call to complete. During this time, the thread does not use the processor, and the scheduler switches to executing other threads or processes.

In detail:

  • When a thread makes a blocking operation (e.g., reading from a file or waiting for input/output), it is moved to a waiting (blocked) state.
  • The scheduler removes this thread from the ready queue and selects another thread that can be executed.
  • Once the system call completes (e.g., data is ready), the thread is moved back to the ready state.
  • The scheduler will then allocate CPU time to this thread.

Thus, a blocking call leads to a context switch and allows efficient CPU utilization, avoiding idle waiting for the operation to complete.