Learning outcomes
- Describe a process’s address space layout and the information used to identify processes.
Describe a process’s address space layout and the information used to identify processes.
A process is a program in execution. To run correctly, every process must have its own logical memory arrangement and its own identity within the operating system. The memory arrangement is called the process address space, while the identity is defined through process-related identifiers such as the process ID, parent process ID, and related execution information.
The operating system uses the address space to manage execution and memory access, and it uses process identifiers to distinguish one process from another. These two ideas are closely related to process creation, execution, protection, and scheduling.
The address space tells us how a process is laid out in memory.
The identification information tells the OS exactly which process it is managing.
A process address space is the range of logical addresses that a process can use during execution. It contains the program instructions, data, dynamically allocated memory, and function call information needed by the process.
In simple terms, it is the memory view that belongs to one isolated process. Even if two processes run the exact same program, each process normally has its own separate address space. This provides isolation and prevents one process from directly interfering with another.
A standard process address space is commonly explained using four major regions: Text (Code), Data, Heap, and Stack.
Contains the executable instructions of the program. It stores the compiled machine code run by the CPU. It is usually treated as read-only to protect the code from accidental modification.
Stores global and static variables. Divided into Initialized data (variables given an initial value) and Uninitialized data (BSS) (variables declared without an explicit value).
Used for dynamic memory allocation during execution (e.g., malloc() or new). Grows upward as more memory is requested. Useful when size isn't known in advance.
Stores function call frames. Includes local variables, parameters, and return addresses. A new frame is created on function call and removed on return. Grows downward.
In the usual textbook view, the heap grows upward and the stack grows downward. The free space between them allows the process to expand dynamically during execution. If either region grows excessively and they collide, it causes a memory-related error (like a Stack Overflow).
A process has its own isolated address space. If it crashes, others are safe.
A thread shares the Code, Data, and Heap with other threads of the same process, but maintains its own separate Stack and CPU registers.
The operating system must uniquely identify each process to manage it. It does so using identifiers, most of which are stored in the Process Control Block (PCB).
top or ps commands).
During process creation, a new process receives its own unique PID. In a typical UNIX/Linux fork()-based model:
exec(), the entire address space is replaced by the new program, but the PID remains the exact same.The address space gives structure to the memory used by a process. Process identification gives structure to the operating system’s control over that process. Together, they support execution, protection, memory allocation, scheduling, and process hierarchy.
In short, a process is not just “a running program.” It is a managed execution entity with a defined memory layout and a unique identity in the OS.
Suppose process P1 is executing a standard C program containing:
int count = 10;int* arr = malloc(100);calculate() with local variables.count is stored in the Data Segment.malloc() is taken from the Heap.calculate() are pushed onto the Stack.exec() to run a completely different program, its memory is overwritten with the new program, but its PID remains 4051.A process address space is the logical memory space available to an isolated process during execution. It is composed of four main regions:
The operating system identifies a process using metadata. The most important identifier is the Process ID (PID), which uniquely identifies the process for scheduling and signaling. It also tracks the Parent Process ID (PPID) to maintain a family tree.
During process creation, a child process gets a brand new PID. If that process later loads a new program with the exec() system call, its memory layout is replaced with the new code and data, but the PID remains unchanged.
Consider a process P1 running a simple program that contains:
int total = 100;,compute() with local variables, andmalloc().When the program is loaded, the executable instructions are placed in the text (code) segment. This region contains the machine instructions that the CPU executes.
The variable total is stored in the data segment
because it is a global variable with program-wide scope.
When compute() is called, a new stack frame is created in the
stack. This frame stores local variables, parameters, and the return address.
When the function finishes, this stack frame is removed.
Suppose the program executes:
int *arr = (int *) malloc(50 * sizeof(int));
The required memory block is allocated from the heap. Unlike stack memory, this memory remains allocated until it is explicitly released.
The operating system assigns a unique PID to this process, for example PID = 1200. If this process was created by another process, it also has a PPID. These identifiers allow the operating system to manage, monitor, and control the process correctly.
If P1 creates a child process using fork(), the child receives a new PID.
The child gets its own process image and address space.
If the child then calls exec(), its program image changes, but its PID remains unchanged.
Conclusion
This example shows that a process is identified not only by its PID, but also by its memory organization. The code segment stores instructions, the data segment stores global/static data, the heap stores dynamic memory, and the stack stores function call information.
A process address space is the logical memory layout available to a process during execution. It is commonly divided into four main regions: text/code, data, heap, and stack. The text segment stores executable instructions, the data segment stores global and static variables, the heap stores dynamically allocated memory, and the stack stores local variables, parameters, and return addresses used during function calls.
In the usual process layout, the heap grows upward as dynamic memory is allocated, while the stack grows downward as function calls are made. Each process normally has its own address space, which provides protection and isolation from other processes. Threads within the same process share code, data, and heap, but each thread has its own stack and register context.
The operating system identifies a process mainly by its Process ID (PID), which is a unique number assigned to that process. A process may also have a Parent Process ID (PPID) showing which process created it. In multiuser systems, user and group ownership information may also be associated with the process.
During process creation, a new child process receives a new PID.
If that process later loads a different program using exec(),
the program image changes but the PID remains the same because it is still the same process from the operating system’s point of view.
Therefore, process address space explains how a process is organized in memory, while process identification explains how the operating system uniquely recognizes and manages it. Both are fundamental to process execution, protection, and process management.