108 / 163 · C11 · 8 min
The Abstraction: The Process
This chapter introduces the process as the OS abstraction of a running program, explains CPU virtualization, the composition of process state, and how processes are created from programs.
In this lesson
The Nature of a Process
A process is the operating system's way of turning a static program into a dynamic executing entity. The program file contains instructions, but it becomes a useful process only after the OS loads and schedules it. This enables users to run multiple applications at once without directly managing hardware.
Virtualizing the CPU with Time Sharing
To make a limited number of physical processors appear as many, the OS employs time sharing: briefly running one process then switching to the next. This mechanism, combined with scheduling policies, provides the illusion of concurrent execution, though it may affect the speed of individual programs.
Process State and Creation Details
Process state encompasses addressable memory (code, data, heap, stack), key registers (such as the program counter and stack pointer), and open files. During creation, the OS reads the executable from disk into memory, allocates stack and heap, sets initial register values, then begins execution.
Pitfalls
- Equating the program file on disk directly with a process
- Underestimating the performance impact of time sharing
- Omitting registers as part of the process state
Run an example
Minimum C11 · complete program · Download .c
#include <stdio.h>
int main(void) {
printf("Process abstraction in action.\n");
return 0;
}
Compile locally
gcc -std=c11 -Wall -Wextra -Wpedantic -Werror ostep-04-processes.c -o example && ./exampleExpected result
Process abstraction in action.
CHECK YOUR UNDERSTANDING
Close the answer. Explain it.
What are the main parts of a process's machine state? Why is the program counter important?
Show a reference answer
Mainly the memory address space, registers, and I/O information. The program counter is important because it points to the next instruction to execute.
Check the sources
Drafts and official chapters change. The version mark is only the example’s minimum.