Processes Flashcards
3 major aspects of a process
- State of execution (program counter, stack)
- State data in memory (state data in register)
- Might require specialized hardware (I/O devices)
How is a process made?
An application is stored on disk. When it gets launched, its binary gets executed and placed into main memory (in ready state) and becomes a “process” - an active entity
A process can be viewed as an “execution state” of an active application
What are the parts of a process?
All parts are uniquely identified by its address space or stack. Parts of the stack are text = static code, data = global vars set at initialization, heap, and stack (which dynamically changes via LIFO during execution)
What are page tables used for?
- converts virtual addresses in stack and maps it to physical addresses in main memory (DRAM)
- this makes physical memory management simpler
- O/S dynamically sets page tables and will not assign a 1:1 mapping to save physical memory. O/S may also swap parts of a process to disk space when context switching
- also lists what accesses are allowed for a given user
What data structure(s) does the O/S use to know what a process is doing at any given time?
Process Control Block
There are several bits of info (in PCB) to keep track. A couple of important items are Program Counter (and CPU registers), Stack Pointer, list of open files, page table, execution time of process, process priority, max memory usage and more.
Stack pointer is maintained in DRAM memory. Stack pointer points to top of process stack.
What does CPU use to keep track of where a process is during execution
+ Program Counter
Program counter is maintained on CPU. There are also other registers on CPU that keep track of addresses for status information, argument values. All these are part of the state of a process.
The program counter is updated on PCB only for a context change.
What is a Context Switch?
What are the costs of a Context Switch?
When O/S changes from scheduling a process to another process. All state must be saved to the PCB for the first process, then all state for new process from its PCB is initialized to CPU registers.
Costs of context switch are:
- direct costs - the number of cycles to load and store all values of PCB to and from memory
- indirect costs - the changing of data on the different levels on CPU cache
What is hot and cold cache?
Hot cache - cache hits - is correctly accessing data it is is seeking in the cache
Cold cache - cache misses - when cache is empty or irrelevant data is in the cache
What are the 3 different cache misses?
- Compulsory - at beginning of process, the first access to a PCB, the PCB data must be brought into the cache
- Capacity - when PCB data exceeds the capacity of the cache and blocks are trashed from the cache
- Conflict - when several PCB blocks are mapped to same block frame. also called collision or interference misses