Definition
OS Execution within User Processes
OS execution within user processes is a modern operating system architecture where the kernel code and data are mapped into the address space of every user process. In this model, the OS does not exist as a separate entity but as a privileged part of the process itself.
When a process requires an OS service (e.g., via a system call), it performs a mode switch to kernel mode but remains within its own process context.
Mechanism
- Shared Address Space: Each process has its own private user memory and a shared region containing the OS kernel.
- Separate Stacks: The process uses a User Stack for application code and a dedicated Kernel Stack for OS routines.
- Efficiency: A mode switch is much faster than a full process switch because the memory management mappings (TLB) do not need to be flushed if the execution stays within the same process.
Characteristics
- Performance: High performance for system calls due to reduced switching overhead.
- Integration: Found in most modern general-purpose operating systems like Linux and macOS.
- Context Preservation: The process maintains its identity (PID, priorities) regardless of whether it is currently executing user code or kernel code.
Analogy
This architecture is analogous to a private conductor’s cabin on a train:
- User Process (The Train): Represents the journey.
- OS Kernel (The Conductor): Can step into the engine room at any time to perform duties.
The journey does not stop for the conductor to work; instead, the conductor becomes a participant in the journey itself, using the train’s own internal facilities.