1. Home
  2. Explore
  3. Computer Science
  4. Process States and Lifecycle

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Process States and Lifecycle

Process States and the Process Life Cycle

A process is a program in execution. As it progresses, its status changes according to whether it is being created, waiting for CPU time, executing, waiting for an event such as an input/output operation, or finished.

The process-state model is a conceptual way to describe this progress. It helps explain how the operating system manages processes; it is not necessarily a literal representation of every internal kernel data structure.


Primary Process States

The basic process life cycle includes five states:

  • New: The process is being created.

  • Ready: The process is in main memory and able to run, but is waiting for CPU time.

  • Running: The CPU is currently executing the process.

  • Waiting (blocked): The process cannot continue until an event occurs, commonly completion of an input/output operation.

  • Terminated: The process has finished or has otherwise been stopped, and its resources are being reclaimed.

A process can move among these states as it runs. In a single-processor system, only one process can occupy the running state at a time, although many processes can be ready or waiting.

New

The new state represents a process that has been created but has not yet been admitted to the ready queue for execution. For example, when a user starts an application, the operating system creates a process for it.

A program stored on secondary storage is not automatically a running process. The new state refers to the creation and setup of a process instance, rather than simply the existence of a saved program file.

Ready

A process in the ready state has the resources and information needed to run, and is generally resident in main memory, but it is waiting to be assigned a CPU.

Processes waiting in this state are commonly described as being in the ready queue. A scheduler chooses a process from the ready queue according to the operating system’s scheduling policy. The queue is not necessarily first-in, first-out; different scheduling algorithms may select processes by priority, time already used, or other criteria.

Main memory is limited, so the operating system cannot always keep every process in memory at once. It selects a manageable set of processes to admit or retain in the ready state.

Running

A process is in the running state while its instructions are being executed by a CPU.

  • On a single-processor system, at most one process runs at a time.

  • On a multiprocessor system, multiple processes can run simultaneously, subject to the number of available processors.

The process remains in memory while running. Its instructions and data are used by the CPU, and the operating system records its current execution state so it can later resume the process if needed.

Waiting or blocked

A process enters the waiting state, also called the blocked state, when it cannot make progress until some event occurs. A common cause is an input/output request.

For example, a process may request data from a file on secondary storage. Since the CPU can execute instructions much faster than storage devices can supply data, keeping the process on the CPU while it waits would waste CPU time. The operating system therefore blocks it and can schedule another ready process.

When the required event completes—for example, the file data becomes available—the process leaves the waiting state. It normally returns to the ready state, not directly to the running state, because it must wait its turn for CPU time.

Terminated

A process reaches the terminated state when it has completed execution or has been stopped. The operating system can then reclaim resources assigned to it, such as memory and other process-specific allocations.

Termination is different from temporary blocking or preemption: a terminated process is no longer eligible to resume execution as the same active process.


Common State Transitions

The main transitions can be summarized as follows:

  1. New → Ready: The operating system admits the created process to the ready queue.

  2. Ready → Running: The short-term scheduler selects the process, and the dispatcher assigns it to a CPU.

  3. Running → Terminated: The process finishes or is stopped permanently.

  4. Running → Waiting: The process requests an operation or event that it must wait for.

  5. Waiting → Ready: The requested operation or event completes.

  6. Running → Ready: The operating system preempts the process, temporarily stopping its CPU execution so another process can run.

The last transition is especially important in systems that use preemptive scheduling.


Scheduling and Dispatching

Scheduling is the process of selecting which process should run next. The operating system uses different schedulers for different decisions.

Long-term scheduler

The long-term scheduler decides which processes are admitted into the system’s pool of ready processes. It controls how many processes are brought into main memory and thereby influences the degree of multiprogramming.

Its role is especially associated with balancing the number of processes competing for resources. Admitting more processes can improve CPU use when some processes are waiting for input/output, but admitting too many can overburden memory and other resources.

Short-term scheduler

The short-term scheduler chooses a process from the ready queue to run next. It is also called the CPU scheduler. The selected process is passed to the dispatcher, which performs the work needed to start or resume execution on the CPU.

The short-term scheduler is involved frequently because CPU assignments can change as processes finish, block, or are preempted.

Medium-term scheduler

The medium-term scheduler temporarily removes processes from main memory and later brings them back. This is commonly called swapping.

  • Swap out: Move a process from main memory to secondary storage, temporarily freeing memory.

  • Swap in: Bring a suspended process back into main memory when it can continue competing for resources.

This mechanism can help control memory pressure and the number of active processes in memory. The scheduler may choose processes according to factors such as priority or other system policies.


Preemption and Time-Sharing

Preemptive scheduling

In preemptive scheduling, the operating system can interrupt a running process and return it to the ready state before it finishes. This can happen when:

  • A higher-priority process needs CPU time.

  • The running process uses up its allotted time.

  • The operating system otherwise decides to schedule another process.

Preemption lets the operating system share CPU time among processes and respond to important work without waiting for the current process to finish.

Non-preemptive scheduling

In non-preemptive scheduling, a process that has been assigned the CPU keeps it until it finishes or voluntarily gives it up, such as by blocking for input/output. The operating system does not forcibly interrupt it simply because another process is ready.

The distinction is whether the operating system can take the CPU away from a running process before that process finishes or blocks.

Time quantum and round-robin scheduling

A time quantum is a fixed interval during which a process may use the CPU before being interrupted. In round-robin scheduling, ready processes take turns receiving CPU time.

When a process’s time quantum expires:

  1. The operating system interrupts the process.

  2. If it has not finished, it is placed back in the ready queue.

  3. Another ready process is given the CPU.

  4. The interrupted process may run again when its turn arrives.

If a process finishes before its quantum expires, it terminates rather than returning to the ready queue. Round-robin scheduling is a form of preemptive scheduling.


Multiprogramming and Multitasking

Multiprogramming means keeping multiple processes available so the CPU can work on another process when one cannot proceed—for example, when it is waiting for input/output. Its central purpose is to improve CPU utilization by reducing idle time.

Multitasking refers to the system’s ability to make progress on multiple tasks over time. On a single CPU, tasks do not execute simultaneously; the operating system switches the CPU among them, often using preemption and time slices. On a multiprocessor system, some processes may truly execute at the same time on different CPUs.

These ideas are related but emphasize different aspects: multiprogramming concerns having several processes available, while multitasking concerns sharing execution among tasks.


Suspended Process States

The basic five-state model can be extended with suspended states. These describe processes that have been temporarily removed from main memory, often because memory is full or the operating system needs to make room for other work.

Suspended waiting (suspended blocked)

A process that is waiting for an event may be moved from main memory to secondary storage. It is then in a suspended waiting state: it is still waiting for the event, but it is not currently occupying main memory.

When the event completes, the process may become ready to run eventually. If there is not enough room in memory, it can remain suspended until the operating system can bring it back.

Suspended ready

A process that is ready to run but has been swapped out of memory is in the suspended ready state. It is eligible to execute in principle, but it must first be brought back into main memory.

A high-priority process may need to be admitted when memory or the ready queue is under pressure. The operating system can suspend or swap out other processes to make room, according to its policies.

Backing store and resumption

The backing store is secondary storage used to hold processes or process information that has been swapped out of main memory. A suspended process may need to return to memory before it can rejoin the ordinary ready or waiting state.

A process’s path depends on both its status and whether memory is available. For example, a suspended process waiting for input/output must have its event completed and be brought back into memory before it can compete for CPU time. A suspended ready process can return to the ready queue once memory is available.

Suspension is temporary removal from main memory; it does not by itself mean that the process has terminated.


Process-State Queues and Resource Limits

The ready and waiting states are often managed using queues, but the operating system’s actual scheduling structures can be more complex than simple lines of processes.

Because both memory and CPU time are limited, the operating system must decide:

  • Which processes to admit to main memory.

  • Which ready process should receive the CPU next.

  • Which process, if any, should be suspended when memory is scarce.

  • When suspended processes can return to memory.

If many processes are waiting for input/output, the operating system may suspend some of them to free memory. If memory is needed for a process that can make progress, the system may also suspend ready processes. The precise choice depends on the operating system’s scheduling and memory-management policies.


Process Information in Operating Systems

Operating systems provide tools for inspecting processes and their status.

  • Windows Task Manager displays processes and other system activity, including applications and background system processes.

  • Unix and Linux systems commonly provide the ps command for displaying process information. Options such as ps -e or ps -u change which processes or details are shown. Output can include process identifiers, commands, and other status information.

These tools offer a practical view of processes that are active or known to the operating system, though their displayed categories may not map exactly onto the simplified state model.


Key Distinctions to Remember

  • Ready versus running: A ready process is waiting for CPU time; a running process is currently using a CPU.

  • Waiting versus ready: A waiting process cannot proceed until an event occurs; a ready process can proceed but is waiting for CPU time.

  • Blocked versus preempted: A blocked process is waiting for an event, often input/output. A preempted process is still able to run but has temporarily yielded the CPU.

  • Terminated versus suspended: A terminated process is finished and has its resources reclaimed. A suspended process is temporarily removed from memory and may resume later.

  • Long-term versus short-term scheduler: The long-term scheduler controls admission of processes; the short-term scheduler selects a ready process for CPU execution.

  • Preemptive versus non-preemptive scheduling: Preemptive scheduling can interrupt a running process; non-preemptive scheduling lets it continue until it finishes or blocks.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent