Processes and Threads Flashcards
The Three Process States
- Ready
- Blocked (waiting)
- Running
Call Stack
Stack data structure that stores info of active function calls. Composed of stack frames. Grows when new call issues and shrinks when function call returns.
Stack Frame
Part of a call stack. Corresponds to a function call. Includes:
- passed-in args
- return address
- saved register values
- local variables
esp
Stack pointer, holds top of stack
ebp
Base pointer, stores previous esp value, restored after function return
Execution Context
Content of the CPU registers at any point of time (also known as processor state). Includes:
- program counter
- call stack pointer
- location of allocated memory
Program Counter
Specialized register that indicates the address of the instruction to be executed next
Call Stack Pointer
Indicated top of the kernel-space call stack for the process (esp?)
Process State VS Processor State
Process State: running/blocked/ready
Processor: execution content
PCB
Process Control Block, instance of a data structure in the kernel mem containing info needed to manage a particular process.
What is stored in a PCB?
- execution context info
- process ID
- process control info (scheduling state, opened FDs, more…)
Process Switch
Occurs when OS Scheduler suspends the execution of one process on CPU and runs another. 1st process in scheduled out the second process is scheduled in.
Process Switch Steps
- Store context of current process into its PCB
- Scheduler picks a process in the ‘ready’ list
- Use PCB of picked process to restore contents of the CPU registers
When does Process Switch occur?
- process blocks
- process yields
- process exits
- CPU time slice is used up
CPU Timing
Timer issues interrupt. CPU time allocation under control of CPU