Processes
Logical control flow
-
A process provides each program with the illusion that it has exclusive use of the processor, even though many other programs are typically running concurrently on the system.
- Processes takes turns using the processor.
- Each process executes a portion of its flow and then is
preempted
(temporarily suspended) while other processes take their turns. - Each time the processor stalls, it subsequently resumes execution of our program without any change to the contents of the program’s memory locations or registers
Private address space
- A process provides each program with the illusion that it has exclusive use of the
system’s address space. Each such space has the same general organization (see figure 8.13)
- The bottom portion (from 248-1) is reserved for the user program (usual code, data, heap and stack segments).
- The code segment always begins at address
0x400000
. - The top portion is reserved for the kernel (shared between processes). This contains the code, data and stack that the kernel uses when it executes instructions on behalf of the process ( system call).
- On a machine with n-bit addresses, the address space is the set of 2n possible addresses, 0, 1,…,2n − 1.
User and kernel modes
- The processor provides a mechanism that restricts the instructions that an application can execute, as well as the portions of the address space that it can access.
- Processors typically provide this capability with a mode bit in some control
register that characterizes the privileges that the process currently enjoys.
- When the mode bit is set, the process is running in
kernel mode
: process can execute any instruction and access any memory location in the system. - When the mode bit is not set, the process is running
- When the mode bit is set, the process is running in