Process States and Lifecycle


Process States and Lifecycle

Michael
Welcome! Today we’re unpacking process states—the stages a process can pass through from creation to completion. One important framing point: these states are a teaching model. They help us understand how a process moves through a system; they aren’t necessarily a literal picture of every detail the operating system tracks internally.

Anna
And we’ll start with the five primary states: new, ready, running, waiting or blocked, and terminated. Then we’ll add the two suspended states and connect the whole life cycle to the three schedulers.

Michael
First is new. A process is new when it has been created, but it hasn’t yet been admitted to the ready state to compete for CPU time. Think of a program being launched: the system now has a process to manage, and the process begins its life cycle.

Anna
So new doesn’t simply mean that a program file exists on disk. The key idea is that the process has been created, and it’s at the beginning of its managed life cycle.

Michael
Right. Next comes ready. A ready process is in main memory and has what it needs to wait for CPU service, but it isn’t executing at this moment. Ready processes wait in the ready queue.

Anna
And there may be many processes in secondary storage, but not all can necessarily be brought into RAM at once. Memory is limited, so the system has to choose which processes enter the ready queue.

Michael
That admission role belongs to the long-term scheduler. It selects processes to bring into the ready state. A related idea is multiprogramming: keeping multiple processes available in memory so the system has processes ready to run.

Anna
Once a process is ready, how does it actually get the CPU?

Michael
The short-term scheduler chooses a process from the ready queue and dispatches it to the running state. Running means the process is currently executing on a CPU. In the single-processor model we’re using, only one process runs on that processor at a time.

Anna
That distinction is useful: a process can be in RAM in either the ready or running state. Its status changes when it gets the CPU, not because it has left memory.

Michael
Exactly. While running, the CPU carries out the process’s instructions. If the process finishes its work, it moves to terminated. At that point, the system can reclaim the memory and other resources that had been assigned to it.

Anna
So the basic path is new, then ready, then running, and finally terminated—unless something interrupts that straightforward route.

Michael
One common interruption is preemption. Suppose a process is running and a higher-priority process needs the CPU. The running process can be stopped and returned to the ready queue, so the scheduler can run the higher-priority one.

Anna
A time quantum can cause the same kind of transition. In round-robin scheduling, each process gets the CPU for a limited interval. If its time runs out before the process finishes, it goes back to ready and can have another turn later.

Michael
When a running process is interrupted and returned to ready, that’s a preemptive situation. The reason might be priority or an expired time quantum. If the process instead keeps the CPU until it finishes, without being interrupted in that way, that’s non-preemptive scheduling.

Anna
So preemptive and non-preemptive describe whether a running process can be made to give up the CPU before it completes. That’s different from multiprogramming, which is about having multiple processes available in memory.

Michael
And multitasking is the appearance of making progress on multiple processes over time. On one processor, the CPU switches between processes rather than executing several at the exact same instant. Preemption and time-sharing can help make those turns happen.

Anna
There’s another reason a running process may stop using the CPU: it might request input or output. For example, it may need to read a file from secondary storage or communicate with a device.

Michael
That process can’t make useful progress on the CPU while it waits for the I/O operation, so it moves to the waiting—or blocked—state. The CPU can then run another ready process instead of sitting idle while the slower operation completes.

Anna
And when the I/O finishes, the process doesn’t jump straight back into running. It returns to ready, where it waits for the short-term scheduler to give it another turn.

Michael
That gives us the central difference between preemption and blocking. With preemption, the system takes the CPU away from a process that can still run. With blocking, the process gives up the CPU because it is waiting for an event, such as an I/O operation, to complete.

Anna
Now let’s add the suspended states. Why would a process need to be suspended if it’s already waiting or ready?

Michael
Because RAM is limited. If many processes are waiting for I/O, the waiting queue can consume memory. The medium-term scheduler can move a process out of main memory and into secondary storage temporarily. That movement is called swapping out, and the process enters suspended wait, or suspended block.

Anna
So a suspended-wait process is waiting for its I/O-related work, but it has also been moved out of RAM to relieve memory pressure. Once it can be brought back, it can continue through the waiting and ready states as appropriate.

Michael
There can also be pressure in the ready state. If the ready queue is full and a process needs to be held out of RAM—for example, to make room for a higher-priority process—it can be moved to suspended ready. When space becomes available, it can be resumed into the ready state.

Anna
The key distinction is what the process was doing before suspension: suspended wait comes from a blocked process, while suspended ready comes from a ready process. In both cases, the medium-term scheduler is associated with moving processes out of and back into memory.

Michael
And a suspended process may have to wait for room in the relevant queue before it can return. The overall route is not a direct jump from suspended to running: a process must get back into an appropriate in-memory state, and a ready process still needs to be dispatched.

Anna
How does the medium-term scheduler decide which processes to swap out?

Michael
The material describes that choice as depending on a scheduling policy. It might consider priority or use a frequency-based criterion, such as least frequently used or most frequently used. The point is that the scheduler selects processes according to its logic to make room.

Anna
So the three schedulers have different jobs: long-term admits processes to ready, short-term dispatches a ready process to the CPU, and medium-term can swap processes out of memory and later bring them back.

Michael
Exactly. And the life-cycle model helps connect those jobs. A process is created, admitted to ready, dispatched to running, and may finish. Or it may be preempted back to ready, block while waiting for I/O, or be suspended when memory pressure requires it.

Anna
For a practical way to inspect processes, the lesson also points to operating-system tools. Windows Task Manager displays a list of processes, including system and user processes.

Michael
On Unix or Linux, the ps command provides process information, including process IDs and commands. There are variations such as ps -e and ps -u, but ps is the general command introduced here.

Anna
Let’s finish with the exam-ready summary: know the five primary states and what causes transitions between them; distinguish ready from running and waiting; understand preemptive versus non-preemptive scheduling; and remember the suspended states and the medium-term scheduler.

Michael
And keep the scheduler roles straight: long-term brings processes into ready, short-term selects one for running, and medium-term manages swapping when memory pressure calls for it. That’s the process life-cycle model, from creation through execution, waiting or suspension, and ultimately completion.

Ask anything
We've read this whole study set, so questions about it get the best answers.