Facebook Pixel

Operating System Operations on Processes

What is a Process in an OS?

A process is essentially a program that is currently being executed. During its lifecycle, it moves through various stages, and at each stage, specific operations are performed that help the process progress toward completion.

Process States Overview

A process does not remain static; it transitions through multiple states during execution:

  • New: The process is being created.
  • Ready: All required resources are allocated, and the process is waiting for CPU time.
  • Running: The CPU is actively executing the process instructions.
  • Waiting (Blocked): The process is paused until a particular event occurs, such as completion of an I/O operation.
  • Terminated: The process has finished execution and is removed from the system.
Process States Diagram

A standard process transitioning through states

Operations on Processes

Process operations occur either when a process is in a specific state or when it moves from one state to another. The main operations include:

  • Process Creation
  • Process Dispatch
  • Process Preemption
  • Process Blocking
  • Process Termination

1. Process Creation

This is the initial step when a process enters the system and corresponds to the New state. A process can be created in several ways:

  • System startup: The OS creates essential system and background processes during boot.
  • User action: When a user runs an application.
  • Creation by another process: A running process can generate a new one using system calls.
  • Batch processing systems: Jobs are created automatically.
Forking and Child Processes
In many systems, a new process is created using the fork() system call. The original process is known as the parent, while the newly created one is called the child. A parent can have multiple child processes, but each child has only one parent. Initially, both share similar attributes like open files and environment data, but they operate in separate memory spaces.
Process Creation Diagram

A parent process creating child processes

2. Process Dispatch

Dispatching occurs when the scheduler selects a process from the Ready state and assigns it to the CPU for execution.

During dispatch, the system loads the process's state from its Process Control Block (PCB) so execution can begin. This can happen under several conditions:

  • The CPU becomes free
  • The current process finishes its time slice
  • A higher-priority process arrives
  • A hardware interrupt occurs

3. Process Preemption

Preemption refers to temporarily stopping a currently running process so another process can use the CPU.

When preemption happens, a context switch takes place. The current process's state is saved in its PCB, allowing it to resume later from the exact same point.

  • Time slice expires: The process has used up its allotted quantum of CPU time.
  • Higher-priority process: A more important process enters the system and demands immediate CPU attention.
  • Interrupt occurs: A hardware interrupt forces the CPU to switch contexts.
Process Preemption Diagram

Preempting a running process to allocate CPU elsewhere

4. Process Blocking

A process moves to the Waiting state when it cannot continue execution until a certain event occurs.

In such cases, the OS removes the process from the CPU. Once the required event is completed, the process returns to the Ready state to await execution again.

  • Waiting for input/output operations to complete
  • Waiting for system resources or signals from other processes
Process Blocking Diagram

A process blocking while waiting for resources

5. Process Termination

Termination marks the end of a process, after which all its allocated resources are released.

  • It completes its execution normally.
  • It is terminated intentionally by its parent process.
  • Fatal errors or exceptions occur.
  • Hardware failures happen.
Termination Cleanup Steps
When a process ends, it sends a termination signal (like SIGTERM). The process performs cleanup by releasing memory, closing open files, and updating shared data. Then, it exits, and control returns to the parent or OS. Remember: if a parent process terminates, its child processes are usually terminated as well.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.