Week 5 Flashcards
Page Fault Handling
Hardware Trap and Register Save:
The MMU traps the CPU to the OS, storing essential data and program counter on the stack.
Interrupt Service Routine (ISR):
ISR, written in assembly, saves registers and calls the page fault handler.
Virtual Page Identification:
OS identifies the required page, accessing data from hardware registers or parsing instructions.
Validation and Protection Check:
The OS verifies the address; invalid addresses terminate the process.
Page Frame Management:
The OS uses free frames or replacement algorithms for page loading; if dirty, the page is saved to disk.
Disk/SSD Operation:
The page is loaded into memory and flagged to prevent reuse.
Process Suspension and Resumption:
The OS suspends the faulting process and schedules another if possible.
Page Arrival and Update:
Page tables are updated when the page arrives.
Instruction Backup and Program Counter Reset:
The OS resets the program counter to re-execute the faulting instruction.
Process Scheduling and ISR Conclusion:
The faulting process is rescheduled, and the ISR restores the original context.
Local vs. Global Allocation Policies
Local Allocation: Allocates frames per process based on its page fault history (e.g., local LRU).
Global Allocation: Manages frames for all processes, with a single page replacement queue (e.g., global LRU).
Considerations:
Frame allocation per process.
Monitoring working set size to avoid thrashing.
Page Fault Frequency (PFF) Algorithm
PFF Monitoring: Tracks page faults per process.
Thresholds:
If page faults exceed threshold A, allocate more memory.
If faults are below threshold B, reduce memory.
If all processes reach threshold A, thrashing occurs, and load control may be required.
Load Control
Out of Memory (OOM) Killer: Terminates or swaps out processes if memory is overloaded.
Compaction and Deduplication: Clear space by combining fragmented memory or using same-page merging for identical pages across processes.
Cleaning Policy
Paging Daemon: Clears dirty frames to disk in the background, ensuring clean frames are available.
Page Sizes
Page Size Selection:
OS determines page size, commonly 4KB or larger.
Fragmentation occurs when small segments occupy a full page, wasting space.
Page Table Size increases with smaller pages, impacting TLB and memory.
Shared Pages and Libraries
Shared Pages: Allow multiple processes to use the same code page, reducing memory usage.
Shared Libraries: Libraries loaded once by one process become accessible to others, saving memory and resources.
Implementation Issues
Process Lifecycle:
Memory allocation during creation, page table updates during execution, and release of resources on termination.
Segmentation
Segmentation: Divides memory into variable-length segments.
Useful for managing memory based on logical divisions (e.g., code, data).
However, growing segments can lead to fragmentation and underutilized space.