Process In Operating System
A process is a program in execution—it has a current state, uses CPU, memory, and other resources. It is the active (running) instance of a program. When you double-click an application or run a command, the OS loads its program code into memory and starts executing it as a process.
What exactly happens after you click an app?
When you click a program or app, the operating system performs these steps:
Step1: Loads the program into memory (RAM)
The executable file’s instructions and required resources are copied from disk into main memory.
Step2: Creates a Process Control Block (PCB)
The OS makes a data structure called PCB that stores the process ID, current state (ready/running), CPU register values, memory details, etc.
Step3: Allocates resources
CPU time, memory space (stack, heap, data segment), and any input/output resources are reserved for the process.
Step4: Starts execution
The CPU begins running the program’s instructions. Now the program is a process (a running instance of that program).
How Does a Process Look Like in Memory?
When a program is loaded into the memory and it becomes a process, it can be divided into four sections stack, heap, text and data. The following image shows a simplified layout of a process inside main memory −

Text (Code) Segment:
- Holds the compiled machine instructions of the program.
- It’s usually read-only, so you can’t accidentally overwrite your own instructions.
- Example: the binary code for printf() or your app’s main logic.
Data Segment:
- This section contains the global and static variables.This is split into two parts
- Initialized data: global and static variables with an initial value (e.g., int count = 5;).
- Uninitialized data (BSS): global and static variables without an initial value (e.g., int total;).
Heap:
- Memory allocated dynamically at runtime.
- Grows upward (towards higher addresses) as you create objects using malloc(), new, etc.
- Freed when the process ends or you explicitly release it.
Stack:
- The process Stack contains the temporary data such as method/function parameters, return address and local variables.
- Grows downward (towards lower addresses).
- Automatically managed: when a function ends, its stack frame is popped.
Process Control Block (PCB)
Process Control Block (PCB) is a data structure in the operating system that contains all the information about a specific process, so the OS can manage and control it. A process has several important attributes that help the operating system manage and control it. These attributes are stored in PCB.
- Whenever a process is created, the OS makes its PCB.
- Whenever the process is running, waiting, or stopped, the OS updates its PCB.
A PCB stores all important details of a process. Here are the main fields (grouped for easy understanding):
- Process ID (PID): A unique number assigned to each process so the operating system can identify it.
- Process State: This shows the current status of the process, like whether it is running, waiting, or ready to execute.
- Priority and other CPU Scheduling Information: Data that helps the operating system decide which process should run next, like priority levels and pointers to scheduling queues.
- I/O Information: Information about input/output devices the process is using.
- File Descriptors: Information about open files files and network connections.
- Accounting Information: Tracks how long the process has run, the amount of CPU time used, and other resource usage data.
- Memory Management: Details about the memory space allocated to the process, including where it is loaded in memory and the structure of its memory layout (stack, heap, etc.).
A Process Control Block (PCB) is the complete record of a process—its ID, state, CPU/memory details, and resources. Without PCBs, the OS wouldn’t know which processes exist, what they’re doing, or how to resume them after an interrupt or context switch.
Process States
When a process executes, it passes through different states. These states show what the process is currently doing (running, waiting, etc.). So, a process state shows the current activity of a process— whether it’s waiting, running, or finished. The OS keeps track of these states inside the Process Control Block (PCB) so it can manage scheduling and resources.
Most operating systems (Windows, Linux, macOS) define five fundamental states:

1. New State:
This is the initial state when a process is first started/created. It has not been loaded into the main memory, but its process control block (PCB) has been created, which holds important information about the process.
2. Ready State:
A process in this state is ready to run as soon as the CPU becomes available. It is waiting for the operating system to give it a chance to execute. Process may come into this state after Start state or while running it by but interrupted by the scheduler to assign CPU to some other process.
3. Running State:
This state means the process is currently being executed by the CPU. Since we’re assuming there is only one CPU, at any time, only one process can be in this state.
4. Waiting State:
Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available.
5. Terminate State:
Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state and removed from main memory.