Learn

To best optimize the performance of processes as their priority changes or as they wait for access to a limited resource, processes are put into one of five states:

  • New: The program has been started and waits to be added into memory in order to become a full process.
  • Ready: Process fully initialized, loaded into memory, and waiting to be picked up by the processor.
  • Running: Currently being executed by the processor.
  • Blocked: The process requires a contested resource that it must wait for.
  • Finished: The process has been completed.

The life cycle of a process is its journey between these five states, beginning with New and ending with Finished. As CPU cores traditionally only executed one task at a time, managing the state of processes allows the processor to interleave these tasks and allows multiple processes to best share these cores and other limited computer resources. For example, instead of a process occupying the processor while waiting for user input, it can be marked as blocked to have the processor focus on another process in the ready state until that input arrives.

Blocking isn’t inherently negative as some tasks require more time. Marking these processes as blocked allows the processor to prioritize other tasks, creating a more responsive and efficient system. Similarly, some processes may also be reverted to the Ready state through preemption, where tasks are temporarily interrupted by an external scheduler for urgent reasons, such as a hardware interrupt signal asking the system to shutdown.

All of these switching processes do come with overhead that is best to be avoided. This is called context switching and is typically an expensive operation as the current state of the process needs to be stored and then be reloaded later to resume execution.

Instructions

How could the Blocked state be further broken down to be more descriptive?

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?