TutorialsOperating Systems
Core CS

Process Concept

A process is simply a computer program currently in execution. While a program sitting on a hard drive is passive, like a recipe in a book, a process is active—it is the computer actively reading the instructions, using memory, and utilizing the CPU to carry out tasks.

<p></p><h2><!--StartFragment--><p><b>Definition&nbsp;</b></p><p>A process is the fundamental unit of work in a modern operating system. It consists of more than just the source code; it represents an entire execution environment loaded into the system's main memory (RAM). When an executable file (like a browser, text editor, or background service) is launched, the operating system allocates dedicated memory and resources to turn that static file into an active, running process managed by a data structure called the <b>Process Control Block (PCB)</b>.</p><p>In memory, a process is structured into four primary sections:</p><ul><li><p><b>Text Section:</b> The compiled machine code instructions being executed.</p></li><li><p><b>Data Section:</b> Global and static variables allocated before program startup.</p></li><li><p><b>Heap:</b> Dynamically allocated memory requested during runtime (e.g., using <code>malloc</code> in C or <code>new</code> in Java/C++).</p></li><li><p><b>Stack:</b> Temporary memory storing local variables, function parameters, and return addresses.</p></li></ul><p><b>Key Features of a Process</b></p><ul><li><p><b>Dynamic Nature:</b> Unlike static files, a process constantly changes its internal values, registers, and operational state over time.</p></li><li><p><b>Isolated Address Space:</b> Operating systems assign each process its own virtual memory boundary, preventing one process from accidentally corrupting or crashing another.</p></li><li><p><b>Resource Allocation:</b> Every process receives and tracks its own set of system resources, including CPU time slices, open files, network sockets, and I/O devices.</p></li><li><p><b>Identifiable Tracking:</b> Each process is assigned a unique integer identifier called a <b>PID (Process ID)</b> that the OS uses for monitoring, scheduling, and termination.</p></li><li><p><b>Process Control Block (PCB):</b> The OS maintains a dedicated record per process containing the Program Counter, CPU registers, scheduling priority, and memory management limits.</p></li></ul><p><b>States of a Process</b></p><p>During its lifecycle from startup to shutdown, a process moves through five standard states:</p><ol><li><p><b>New (Created):</b> The initial stage where the process is being created and its program code is being read from disk, but it has not yet been loaded into main memory.</p></li><li><p><b>Ready:</b> The process is fully loaded in main memory and ready to run, simply waiting in a queue for the CPU scheduler to allocate CPU time.</p></li><li><p><b>Running:</b> The CPU is actively executing the process's instructions. In a single-core system, only one process can be in this state at any instant.</p></li><li><p><b>Waiting (Blocked):</b> The process cannot continue executing until an external event occurs, such as waiting for keyboard input, disk read/write, or network data.</p></li><li><p><b>Terminated (Exit):</b> The process has finished its execution or was halted due to an error, and the OS is releasing its assigned resources and memory.</p></li></ol><p><b>Process State Transitions</b></p><p>Processes shift between states based on CPU scheduling, hardware interrupts, and system calls:</p><p><br></p><img src="uploads/tutorials/2026/09/tutorial-20260914-225234-c7ddb1299f2c.png" alt="ChatGPT Image Sep 14, 2026, 10_48_54 PM"><br><p><br></p><!--EndFragment--><!--EndFragment--></h2><p></p>