Formation of Process from Program
Last Updated :
14 May, 2025
A process is a program in execution. It is an active entity that requires system resources such as CPU time, memory, and I/O devices to execute. A program resides in secondary memory (like a hard disk or SSD). For a program to become a process it must go through various actions such as loading the program into memory, allocating memory for the process (code, data, stack, heap), creating a Process Control Block (PCB) to track the process, initializing the CPU context (registers, stack pointer, program counter, etc.), and finally putting the new process into the scheduler’s queue (transitioning it to the “ready” state, and eventually to “running”).
The detailed stages involved in transforming a program into a process are as follows:
1. Program Loading (Loading the Executable into Memory)
- The first step is loading the program from disk into memory. The operating system’s loader is responsible for this. It locates the executable file on storage and reads its contents (the program’s machine code and static data) into memory.
- In this stage, the OS typically creates a new address space for the process and begins populating it with the program’s code (text segment) and initialized data.
- During this loading phase, the OS also prepares basic memory structures for the process’s runtime, such as setting up an initial stack and heap region for the process.
2. Memory Allocation
- Once the executable’s contents are identified, the OS allocates memory for the new process. The memory manager reserves a block of virtual memory for all the components of the process which includes space for the program’s code (text segment), data segments (initialized and uninitialized data), the runtime heap, and the stack.
- During this stage, the OS may also load any necessary shared libraries into the process’s address space (e.g., dynamic link libraries) and set up other memory-mapped resources required by the program.
- The OS also designates space for the heap. By the end of this stage, the new process has a defined virtual address space with all the regions it will need: code, data, heap, and stack are reserved and ready for use.

3. Creating the Process Control Block (PCB)
- In parallel with establishing the memory, the OS creates a Process Control Block (PCB) for the new process. The PCB (sometimes called a process descriptor or task control block) is a data structure in the kernel that holds all the metadata about the process.
- When the process is created, the OS assigns it a unique Process Identifier (PID) and adds an entry for the process in the system’s process table (an index of all active processes). Memory for the PCB itself is allocated (often as part of the kernel’s process table or a separate kernel memory area).
Read more about PCB
PCB4. Setting Up the Execution Context
After loading the program and creating the PCB, the operating system must set up the process’s execution context so that it can actually run. This involves preparing the initial stack contents, the heap pointer, and CPU registers:
- Stack Initialization: The process’s stack region was allocated earlier, now the OS arranges the initial stack frame. This often includes placing the program’s command-line arguments and environment variables onto the stack or in a specific memory region, and setting the stack pointer accordingly.
- Heap Setup: The heap segment is typically empty at start (no allocations done yet), but the OS establishes a pointer (or break value) that indicates the current end of the heap. The OS ensures the process has the right to expand its heap up to some limit. In practice, nothing specific is placed in the heap at creation except setting its boundaries.
- CPU Registers and Execution Start: The OS initializes the CPU register context for the new process so that it can start execution. This includes setting the instruction pointer (program counter) to the program’s entry point. It also sets the stack pointer register to the top of the stack segment that was set up, and may set other registers . Essentially, the OS prepares a context such that if the CPU were to switch to this process, it would start executing the new program from its beginning with a clean stack.
- Kernel/Mode Context: The OS also sets up any needed kernel-mode context for the process. For example, it may allocate a kernel stack for the process/thread (used when the process transitions to kernel mode for system calls or interrupts).
5. Transition to Ready State and Scheduling
- With the new process’s memory and context prepared, the OS can make the process eligible to run. At this point, the process was in a “new” or “created” state (not yet scheduled). The operating system now transitions the process to the Ready state.
- This means the process is added to the system’s ready queue (or an equivalent scheduler data structure), indicating it is now ready to execute whenever the scheduler chooses it.
- Once in the ready state, the new process must wait its turn to use the CPU. The scheduler (part of the OS) will decide when to actually start executing this process, based on scheduling algorithms and policies.
- The new process will remain in the ready queue until the scheduler picks it and dispatches it to the CPU. At that moment, the process state changes to Running, and the CPU begins executing its instructions from the program’s entry point using the context that was set up.
- The OS ensures that if the process is preempted (e.g., its time slice expires or a higher-priority process needs the CPU), the current CPU context is saved (in the PCB or related structures) so that the process can resume correctly later – this is part of normal scheduling and context switching, not specific to creation but crucial for multi-tasking.
- Eventually, the process may finish execution or be terminated, at which point the OS will free its resources and remove its PCB from the process table.
Read more about Process Management
State Transition Diagram in process management
Similar Reads
What is OSI Model? - Layers of OSI Model The OSI (Open Systems Interconnection) Model is a set of rules that explains how different computer systems communicate over a network. OSI Model was developed by the International Organization for Standardization (ISO). The OSI Model consists of 7 layers and each layer has specific functions and re
13 min read
Introduction of ER Model The Entity-Relationship Model (ER Model) is a conceptual model for designing a databases. This model represents the logical structure of a database, including entities, their attributes and relationships between them. Entity: An objects that is stored as data such as Student, Course or Company.Attri
10 min read
DBMS Tutorial â Learn Database Management System Database Management System (DBMS) is a software used to manage data from a database. A database is a structured collection of data that is stored in an electronic device. The data can be text, video, image or any other format.A relational database stores data in the form of tables and a NoSQL databa
7 min read
TCP/IP Model The TCP/IP model (Transmission Control Protocol/Internet Protocol) is a four-layer networking framework that enables reliable communication between devices over interconnected networks. It provides a standardized set of protocols for transmitting data across interconnected networks, ensuring efficie
7 min read
Types of Network Topology Network topology refers to the arrangement of different elements like nodes, links, or devices in a computer network. Common types of network topology include bus, star, ring, mesh, and tree topologies, each with its advantages and disadvantages. In this article, we will discuss different types of n
12 min read
Normal Forms in DBMS In the world of database management, Normal Forms are important for ensuring that data is structured logically, reducing redundancy, and maintaining data integrity. When working with databases, especially relational databases, it is critical to follow normalization techniques that help to eliminate
7 min read
Operating System Tutorial An Operating System(OS) is a software that manages and handles hardware and software resources of a computing device. Responsible for managing and controlling all the activities and sharing of computer resources among different running applications.A low-level Software that includes all the basic fu
4 min read
Computer Network Tutorial A Computer Network is a system where two or more devices are linked together to share data, resources and information. These networks can range from simple setups, like connecting two devices in your home, to massive global systems, like the Internet. Below are the main components of a computer netw
7 min read
ACID Properties in DBMS In the world of DBMS, transactions are fundamental operations that allow us to modify and retrieve data. However, to ensure the integrity of a database, it is important that these transactions are executed in a way that maintains consistency, correctness, and reliability. This is where the ACID prop
8 min read
Types of Operating Systems Operating Systems can be categorized according to different criteria like whether an operating system is for mobile devices (examples Android and iOS) or desktop (examples Windows and Linux). Here, we are going to classify based on functionalities an operating system provides.8 Main Operating System
11 min read