Lecture 7 Flashcards
Address Translation and Paging
What is address translation?
The process of converting a virtual address into a physical address.
What role does the OS play in address translation?
The OS must manage memory and intervene at key points to set up hardware for address translation.
What is a base and bounds register?
Registers used to define the limits of a process’s address space in memory.
What is dynamic relocation?
A technique where the OS can move address spaces even after a process has started running.
Fill in the blank: The physical address is calculated as _______.
virtual address + base
What happens when a process tries to access memory outside its bounds?
The CPU raises an exception, and the OS must handle it.
What is a free list in memory management?
A list that includes the size and location of physical memory that is not in use.
What is a page fault?
An exception that occurs when a program tries to access a page that is not currently in memory.
True or False: The OS installs exception handlers at boot time.
True
How does the CPU detect an invalid memory access?
The CPU sends the virtual address to the Memory Management Unit (MMU) for translation.
What does the MMU check when translating a virtual address?
It checks if the address is mapped and if the program has the right permissions.
What is memory fragmentation?
A condition where memory is divided into small, non-contiguous blocks, leading to inefficient usage.
When does the OS reclaim memory?
When a process is terminated.
What is the purpose of exception handlers in the OS?
To handle errors such as invalid memory access or page faults.
What happens during a context switch?
The OS saves and restores the base-and-bounds pair for different processes.
What is the role of privileged instructions in address translation?
They allow the OS to set base/bounds values and handle exceptions.
What is segmentation in memory management?
A technique used to address the issue of fragmentation.
Fill in the blank: The OS must find space for an address space when a process _______.
starts running
What does the OS do when a page fault occurs and the access is valid?
The OS loads the page from disk and returns to user space.
What are the two types of registers required for address translation?
Base register and bounds register.
What is the significance of the Interrupt Descriptor Table (IDT)?
It helps the CPU find the handler for page faults.
What is the consequence of accessing read-only memory?
It triggers a page fault due to permission violation.
What is fragmentation in memory allocation?
Fragmentation occurs when memory is divided into small, non-contiguous blocks, making it difficult to allocate large processes even when enough total memory is available.
What are the two main types of fragmentation?
- Internal Fragmentation
- External Fragmentation
Define internal fragmentation.
Internal Fragmentation occurs when allocated memory is larger than needed.
Give an example of internal fragmentation.
If a process needs 450 KB, but the system allocates 512 KB blocks, then 62 KB is wasted inside the allocated block.
What causes internal fragmentation?
Fixed-size memory allocation (e.g., paging systems).
Define external fragmentation.
External Fragmentation occurs when free memory is available but in scattered, non-contiguous blocks.
Provide an example of external fragmentation.
Suppose a system has 600 KB of free memory split into three blocks of 200 KB each. If a process needs 500 KB, it cannot be allocated despite sufficient total memory.
What causes external fragmentation?
Dynamic allocation of variable-sized blocks (e.g., Base and Bound).
What are the consequences of fragmentation?
- Inefficient use of memory
- Potentially causing a system to run out of memory for new allocations earlier than necessary
- Slower performance due to additional memory management operations like compaction or paging/swapping
What is the purpose of memory compaction?
Rearranging memory to reduce fragmentation.
List some strategies operating systems use to minimize fragmentation.
- Using paging systems
- Implementing sophisticated allocation algorithms (e.g., best fit, worst fit, first fit)
- Supporting memory compaction
How does Base and Bound suffer from external fragmentation?
The Base and Bound memory management technique assigns a single contiguous block to each process, leading to gaps between allocated memory blocks as processes terminate and new ones are allocated.
What is memory segmentation?
Memory segmentation divides memory into multiple segments, such as code segment, stack segment, and heap segment.
How does segmentation reduce external fragmentation?
Segments can be placed non-contiguously, allowing smaller free spaces to be used efficiently.
What is the history of segmentation in operating systems?
- Early OS used segmentation.
- Burroughs B5000 was the first commercial machine with virtual memory.
- Intel CPUs (8086, 80286, 80386) support paging.
- X86-64 does not use segmentation in 64-bit mode.
What is paging in memory management?
Paging splits up the process address space into fixed-sized units called pages.
What is the difference between segmentation and paging?
Segmentation has variable sizes of logical segments (code, stack, heap), while paging uses fixed-size units.
What is a page frame?
Physical memory is split into a number of pages called a page frame.
What is the purpose of a page table?
A page table is a data structure used to map the virtual address to the physical address.
What does the valid bit in a Page Table Entry (PTE) indicate?
It indicates whether the particular translation is valid or not (swapped or unassigned).
What does the protection bit in a PTE indicate?
It indicates whether the page could be read from (R), written to (W), or executed from (X).
What does the present bit in a PTE indicate?
It indicates whether this page is in physical memory or on disk (swapped out).
What is the dirty bit in a PTE?
It indicates whether the page has been modified since it was brought into memory.
What is the reference bit in a PTE?
It indicates that a page has been accessed for page replacement algorithms.
What is the simplest form of a page table?
A linear page table, which is just an array.
What happens when a page is swapped to disk?
Accessing it will trigger a page fault, and the OS will load it back into RAM.
How does the OS find the desired PTE?
The OS indexes the array by the virtual page number (VPN) and looks up the page-table entry (PTE) at that index.
What register is needed to find the starting location of the page table?
cr3 register
How many extra memory references does paging require for every memory reference?
one extra memory reference
What is the virtual address 21 in a 64-byte address space represented in binary?
010101
What does VPN stand for in memory addressing?
Virtual Page Number
How is the VPN derived from a virtual address?
VPN = (VirtualAddress & VPN_MASK)»_space; SHIFT
What is the formula to compute the address of the page-table entry (PTE)?
PTEAddr = PTBR + (VPN * sizeof(PTE))
What happens if the PTE is not valid during memory access?
RaiseException(SEGMENTATION_FAULT)
What is raised if access permissions in the PTE are insufficient?
RaiseException(PROTECTION_FAULT)
What is the formula to form the physical address from the PTE?
PhysAddr = (PTE.PFN «_space;PFN_SHIFT) | offset
What does a memory trace generate during program execution?
two memory references
What is the major issue in memory allocation that fragmentation refers to?
External fragmentation
What method for memory protection suffers from fragmentation and inflexibility?
Base and Bound Registers
What does segmentation do to memory?
Divides memory into logical sections
What does paging eliminate in memory management?
External fragmentation
What do page tables store information about?
Memory pages, including access permissions
What is a page fault?
An invalid memory access handled by the OS
What optimizations improve performance in paging systems?
Multi-level paging and TLBs
Fill in the blank: The process of addressing translation involves the __________ to fetch the PTE.
page table
True or False: Paging requires variable-size pages to manage memory allocation effectively.
False
What is the purpose of the PTBR in memory management?
Page Table Base Register
What does PTE stand for?
Page Table Entry