Process

Five-State Process Model

Starting point is Two-State Process Model.

Resources

First Primitive

  1. Running: Process is currently executed
  2. Ready: Process is prepared to execute when given the opportunity
  3. Blocked (also called “Waiting”): Process cannot execute until some event occurs, such as the completion of an I/O operation.
  4. New: A process that has just been created but has not yet been admitted to the pool of executable processes by the OS (typically not loaded into main memory, but PCB is created)
  5. Exit: a halted or aborted process (like for Zombie Process)

  • Some other state transitions like ready exit exists (p), but are not shown for clarity
  • In some systems, a parent may terminate a child process at any time. Also, if a parent terminates, all child processes associated with that parent may be terminated.

blocked running: not possible? Needs to transition to ready first. Since it needs to be unblocked, and then the Dispatcher decides

Why do we need a New and Exit state?

The New and Exit states are useful for process management:

  • New: Corresponds to a process that has just been defined. The OS may limit the number of processes on the system
  • Exit: The tables and other information associated with the job are temporarily preserved by the OS, which provides time for auxiliary or support programs to extract any needed information.

For example, a utility program may need to extract information about the history of the process for purposes related to performance or utilization analysis.

Understand Preemption.

The need for swapping

We need to introduce a new suspend state, because blocked processes hog up the Main Memory, whereas we can simply swap them out from main memory to disk.

  • This is called suspending a process

There is a suspend queue of existing processes. When the OS runs out of ready processes, it adds them either from the suspend queue, or admits a new process. Execution then continues with the newly arrived process.

  • However, the above is NOT enough

Why do we need more suspend states?

Elaborated on page 144 of book.

In the diagram above, when a suspended process is transitioned to READY (brought back into main memory), it still is blocked. We should unblock it before bringing it back into main memory.

There are two independent concepts:

  1. whether a process is waiting on an event (blocked or not), and
  2. whether a process has been swapped out of main memory (suspended or not).

This is why we need 2 suspend states, one to mark that it is suspended but still blocked (blocked/suspend), and one to mark that it is suspended and unblocked (ready/suspend).

Final Diagram

  • What do the dotted lines represent? It seems in the textbook (p. 147) that these transitions are valid

The teacher introduces 2 new states:

  • Blocked/Suspend: The process is in secondary memory and awaiting an event.
  • Ready/Suspend: The process is in secondary memory but is available for execution as soon as it is loaded into main memory

Pay attention to the possible state transitions, those are explained at p.146.