Chapter 9+10 Flashcards
(34 cards)
What is difference between logical and physical addresses?
Logical address: generated by CPU during program execution (virtual address). Physical address: actual location in physical memory. MMU translates logical to physical addresses.
Why are page sizes always powers of 2?
Makes address translation efficient using bit shifting. Page number = address»_space; offset_bits. Offset = address & (page_size - 1).
What happens when two page table entries point to same frame?
Creates shared memory between processes. Useful for copying large memory quickly - both pages reference same physical memory. Update in one page visible in other page.
How many bits in logical address for 64 pages of 1024 words?
16 bits total. 6 bits for page number (2^6 = 64 pages). 10 bits for offset (2^10 = 1024 words per page).
How many bits in physical address for 32 frames of 1024 words?
15 bits total. 5 bits for frame number (2^5 = 32 frames). 10 bits for offset (same as page size).
How do first-fit best-fit worst-fit algorithms work?
First-fit: allocate in first partition large enough. Best-fit: allocate in smallest partition that fits. Worst-fit: allocate in largest available partition.
How to calculate page number and offset for address 3085 with 1KB pages?
Page size = 1024 bytes. Page number = 3085 / 1024 = 3. Offset = 3085 % 1024 = 13. Address 3085 is on page 3 offset 13.
How many entries in single-level page table for 21-bit virtual address?
2^21 / 2^11 = 2^10 = 1024 entries (21-bit address 11-bit page size = 10-bit page number).
How many entries in inverted page table?
One entry per physical frame. With 16-bit physical address and 2KB pages: 2^16 / 2^11 = 32 entries.
What is difference between internal and external fragmentation?
Internal: wasted space within allocated memory block (unused space in page). External: free memory exists but not contiguous enough for allocation.
What is required for dynamic memory allocation in contiguous allocation?
Must be able to expand process memory region. Requires free space adjacent to current allocation or ability to relocate entire process.
What is required for dynamic memory allocation in paging?
Allocate additional pages as needed. Page table grows to include new pages. No need for contiguous physical memory.
Why don’t mobile OS support swapping?
Limited storage speed (flash memory wear). Battery life concerns from frequent disk I/O. Solid state storage has limited write cycles. Better to terminate processes.
When do page faults occur?
When referenced page not in physical memory. Page table entry marked invalid or not present. Hardware generates page fault interrupt.
What actions does OS take during page fault?
Save process state. Determine which page caused fault. Check if reference is valid. Find free frame or use page replacement. Load page from storage. Update page table. Resume process.
What is minimum number of page faults for any algorithm?
At least n page faults where n is number of distinct pages in reference string (cold start misses).
What is maximum number of page faults for any algorithm?
At most p page faults where p is length of reference string (worst case: every reference is a fault).
Rank page replacement algorithms from bad to good.
FIFO (suffers Belady’s anomaly) < LRU (no Belady’s anomaly) < Optimal (no Belady’s anomaly best possible).
How does locality of reference affect page faults?
Good locality: recently referenced pages likely to be referenced again reducing page faults. Poor locality: random access pattern causes more page faults.
Why does column-major array access cause more page faults?
Accesses elements far apart in memory. Each array row may be on different page. Row-major access has better locality staying within same page longer.
How many page faults occur in reference string analysis?
Depends on number of frames and replacement algorithm. LRU and FIFO may have different fault counts. Optimal always has minimum possible faults.
Does Belady’s anomaly indicate non-optimal algorithm?
Yes. Optimal algorithms cannot have Belady’s anomaly. If algorithm shows more page faults with more frames it cannot be optimal.
What does CPU 13% disk 97% utilization indicate?
Thrashing: excessive paging. Processes spend more time waiting for pages than executing. Decrease multiprogramming degree.
What does CPU 87% disk 3% utilization indicate?
Good balance: CPU busy but minimal paging. Can possibly increase multiprogramming degree to use more CPU.