When a process comes out of the running state it must be placed back into the ready to run state. However how do we know how far we have got for when we next come to run the process? What was on the stack and do we still need that information. What was in the CPU registers? All this information is required for when the process re-enters the running state. As such it needs to be stored into main memory (or virtual memory). A data structure known as the process control block is used to store all this information.

  • Process Identity Number
  • Current state of the job when the job was last left (stack)
  • The contents of each register when the job was last left
  • What priority the process has
  • Estimated time for the job to be finished
  • Ready to run or blocked
  • memory reserved for this process and resources that could be used.

When the process re-enters the running state, all of its registers and stack entries are reloaded. This is a expensive operation and takes CPU cycles. The more the OS swaps processes, the more time is spent creating and loading process control blocks.

There is a trade off between the average wait time, total running time and number of processes likely to be running. This is a very complicated part of the OS and one which we have only scratched the surface.