Facebook Pixel

What is a Process?

A process is simply a program that is currently being executed. It represents an active entity in the system, performing a sequence of operations step by step.

In simpler terms, when you write a program and save it as a file, it’s just static code. The moment you run that program, it becomes a process, and the system starts executing its instructions.

A process is considered the smallest unit of work handled by the operating system.

Memory Layout of a Process

Process Memory Layout

A typical process memory layout

Once a program is loaded into memory and starts running, it is divided into different sections, each serving a specific purpose:

SegmentPurposeKey Characteristics
StackStores temporary runtime data like function parameters, return addresses, and local variables.Works in a LIFO (Last In, First Out) manner.
HeapUsed for dynamic memory allocation during runtime.Memory is allocated and freed manually (or via garbage collection in some languages).
Data SegmentStores global and static variables.Exists throughout the entire program execution.
Text SegmentContains the actual compiled program instructions.Read-only section, also includes program counter information.

What is a Program?

A program is a set of instructions written in a programming language to perform a specific task. It can be very small or extremely large depending on its purpose.

For example, a simple C program:

c
#include <stdio.h>

int main() {
   printf("Hello, World!\n");
   return 0;
}

Program vs Process

Program vs Process

Comparison between a static program and an active process

A program is passive (just code stored on disk), while a process is active (the program in execution).

So, you can think of a process as a live instance of a program.

Terminology Note
An algorithm is a well-defined set of steps to solve a problem. Software is a collection of programs, along with libraries and related data.

Process Life Cycle

Process Life Cycle

The various states a process moves through during its lifetime

As a process executes, it moves through different stages. While naming may vary across systems, the core states remain similar.

StateDescription
New (Start)The process is actively being created by the OS.
ReadyThe process is prepared to run and is waiting for CPU allocation.
RunningThe CPU is actively executing the process instructions.
Waiting (Blocked)The process is paused until a resource becomes available (e.g., waiting for input or file access).
Terminated (Exit)Execution is completed or stopped, and the process is removed from memory.

Process Control Block (PCB)

The Process Control Block (PCB) is a vital data structure used by the operating system to manage processes. Each process has its own PCB, identified using a unique Process ID (PID).

The PCB exists for the entire lifetime of the process and is deleted once the process finishes execution. It keeps all essential details about a process:

PCB AttributeWhat it Stores
Process StateCurrent status (ready, running, waiting, etc.)
Process ID (PID)Unique numerical identifier for the process
PrivilegesAccess permissions and security credentials
Parent Process PointerLink pointing back to the parent process
Program CounterAddress of the next instruction to be executed
CPU RegistersStored register values so execution can resume later
Scheduling InfoPriority queues and scheduling algorithms details
Memory InfoPage tables, segment tables, and memory limits
Accounting InfoCPU usage, execution time limits, etc.
I/O Status InfoList of I/O devices and open files allocated to the process

Final Note

Summary
Understanding processes, their memory structure, lifecycle, and management is fundamental to grasp how an operating system efficiently runs multiple programs at the same time.

Process Architecture Validation

Question 1 of 2

Test your grasp on programs, processes, and the PCB.

What is the primary difference between a program and a process?
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.