Processes Flashcards
A running program
Process = program in execution. Many processes can run the same programs text and each process has its one address space (isolation). A parent process can create/fork child processes.
Process Isolation
Each process has its own address space and no other process can access this space.
Independent Sequential Processes
Each process has its own program counter, register, variable and flow of control
To run it, copy the logical program counter into the real program counter
When switched, copy the value of the real program counter into the logical program counter in memory.
Processes over time
At any given instance only one process can be active (single CPU)
CPUs switch rapidly between processes, rate of this is completely random and irreproducible
Program
Algorithm expressed in a programming language or other notation
Process
Activity executing on a processor. Has binary program text, input, output, state etc
Interrupt and Switching
Another activity requires CPU
Save state of current process
Switch to the other process with its own program and state
Suspended Processes
Must restart in exactly the same state
The OS saves the address space (the core image) and maintains a process table entry for each process with information about resources (memory locations, open files etc)
Address Space
The OS allocates a private address space to each process isolated from other processes.
The address space has the:
executable program text (the program binary)
program data (global variables to do with the process)
the stack (where the current active functions are stored, one frame per active procedure or function)
dynamically allocated memory
Stack
Automatic (objects only exist for the enclosing scope), managed by the OS
Known at compile time though usage is determined by execution
Heap (Dynamic)
For flexibility, cannot be known until runtime and what cannot fit on the stack
More costly and error prone as programmer requests allocation and deallocation
Process Lifecycle
Processes have a lifecycle managed by the OS from creation to termination
In simple systems, all processes are created at system startup
In general purpose systems, processes need to be created and terminated during operation
System Initialization
Initial tasks reads information about the OS; kicks off the startup initialisation that loads part of the OS and starts it up.
In turn the OS will start other processes such as foreground processes for user interaction or background processes for incoming email, web servers etc
Execution of a process creation system call
Called by a running process; one process starts one process and another starts another process to complete a large job.
Execution of a process creation system call
Called by a running process; one process starts one process and another starts another process to complete a large job.