Memory Management Flashcards
Week 2.9 (75 cards)
define swapping
- moves inactive processes from memory to disk
- OS swaps processes in/out to maximise CPU utilisation
- introduces I/O overhead - overused = v performance
- allows more processes to be managed in limited memory
describe fixed-size partitioning
- divided into fixed-size partitions
- uequal-sized partitions can be used to reduce waste
- process is placed in the smallest available partition that fits
- wasted memory occurs when a process doesn’t fully utilise its allocated partition
describe variable-size partitioning
- each process gets the exact amount of memory it needs
- allocated dynamically - reducing wasted space
- leads to fragmentation over time
what is compaction
solves fragmentation by shifting processes to group freee memory together in large blocks
what is the challenge with compaction
moving processes means changing their memory addresses
solution to compaction challenge
- OS uses logical addresses, which the processor converts to physical addresses at run time
what is address translation
processor uses a base address register to map logical addresses dynamically
what is memory divided into in paging
fixed-size frames
what are programs divided into in paging
fixed-size pages
what is paging
OS assigns pages to available frames
what are page tables
- pages do not need to be stored in contiguous frames
- OS maintains a page table for each processes
- logical addresses = page number + offset
- rocessor uses the page table to translate logical to physical addresses
describe demand paging
- loads process pages into memory only when they are needed
- principle of the locality = programs use a small subset of their code and data at any time
what is a page fault
occurs when a required page is not in memory - OS loads it
what is a page replacement
necessary when bringing in a new page - another page must be removed
what happends from excessive page faults
thrashing - system spends more time swapping pages than executing processes
how does virtual memory add to demand paging
- DP eliminates loading entire processes into main memory
- a process can be larger than physical memory
- OS manages memory allocation dynamically - large programs easier to execute
- real memory = actual physical memory where execution occurs
- virtual memory - perceived memory space, extended onto disk storage
- enables efficient multiprogramming
what is the page table size problem
- each process has its own page table mapping virtual pages to physical frames
- large virtual memory space leads to huge page tables
describe page tables in virtual memory
- page tables are kept in virtual memory
- when a process runs, at least part of its page table must be in memory
- current page table for executing page must always be accessible
what are the 2 solutions to the page table & virtual memory problem
- two-level paging
- intverted paging
describe two-level paging
- a single large page table is split into smaller page tables to save memory
- page Director (Level 1) stores pointers to these smaller page tables
- each Page Table (Level 2) fits within a single memory page
what 3 things is the virtual address made up of in two-level paging
- page directory value - to find the correct PT
- page table index - to locate page inside that table
- offset - to get the exact byte
describe an inverted page table
- virtual page number is mapped into a hash value using a hash function
- hash value points to an entry in the inverted page table
- there is one IPT entry per physical memory frame, not per virtual page
- a fixed amount of memory is allocated for IPT, independent of the number of processes
- if multiple virtual pages map to the same hash value, a chaining method resolves conflicts
what is the performance issue with virtual memory & paging
- every memory access requires two physical accesses : 1st & 2nd
- doubles memory access time, reduces system performance
what is fetched in the first access using virtual memory
fetch the page table entry to translate the virtual address