Podcast
Questions and Answers
What type of addressing do most modern machines use?
What type of addressing do most modern machines use?
What is the function of the MMU in address translation?
What is the function of the MMU in address translation?
Which architecture uses paging in its virtual memory model?
Which architecture uses paging in its virtual memory model?
In a word-addressed machine, how is address 0x1 interpreted?
In a word-addressed machine, how is address 0x1 interpreted?
Signup and view all the answers
What does paging in virtual memory involve?
What does paging in virtual memory involve?
Signup and view all the answers
What is the initial step the kernel takes when handling a page fault?
What is the initial step the kernel takes when handling a page fault?
Signup and view all the answers
How does demand paging improve the loading of executable files?
How does demand paging improve the loading of executable files?
Signup and view all the answers
What happens when brk() or sbrk() is called in a process?
What happens when brk() or sbrk() is called in a process?
Signup and view all the answers
What is a key benefit of demand paging related to memory allocation?
What is a key benefit of demand paging related to memory allocation?
Signup and view all the answers
Which of the following statements about unused pages in demand paging is true?
Which of the following statements about unused pages in demand paging is true?
Signup and view all the answers
What happens when a process attempts to access a page that is unmapped?
What happens when a process attempts to access a page that is unmapped?
Signup and view all the answers
How does the kernel manage the program stack during process creation?
How does the kernel manage the program stack during process creation?
Signup and view all the answers
What occurs when a page is evicted due to low memory on the system?
What occurs when a page is evicted due to low memory on the system?
Signup and view all the answers
What role does the Memory Management Unit (MMU) play in managing the program stack?
What role does the Memory Management Unit (MMU) play in managing the program stack?
Signup and view all the answers
What does it mean when a stack page is marked as 'not present'?
What does it mean when a stack page is marked as 'not present'?
Signup and view all the answers
During the growing of the program stack, what triggers the allocation of new pages?
During the growing of the program stack, what triggers the allocation of new pages?
Signup and view all the answers
Which method describes the process of removing a dirty page from memory?
Which method describes the process of removing a dirty page from memory?
Signup and view all the answers
What is the primary function of the process’s access to the page after a page fault has occurred?
What is the primary function of the process’s access to the page after a page fault has occurred?
Signup and view all the answers
What action does the MMU take when a process tries to use a new page?
What action does the MMU take when a process tries to use a new page?
Signup and view all the answers
What step follows after the MMU notifies the processor about a new page request?
What step follows after the MMU notifies the processor about a new page request?
Signup and view all the answers
What must the kernel do before inserting a new page into the process's page tables?
What must the kernel do before inserting a new page into the process's page tables?
Signup and view all the answers
What function is called by the program to adjust the program break?
What function is called by the program to adjust the program break?
Signup and view all the answers
What happens to the new page after the break is moved?
What happens to the new page after the break is moved?
Signup and view all the answers
What does the kernel do with the unused page during the page allocation process?
What does the kernel do with the unused page during the page allocation process?
Signup and view all the answers
In the context of page faults, what does 'unmapped' signify?
In the context of page faults, what does 'unmapped' signify?
Signup and view all the answers
Regarding page tables, what role do they play in memory management?
Regarding page tables, what role do they play in memory management?
Signup and view all the answers
What is required for managing translation mappings effectively?
What is required for managing translation mappings effectively?
Signup and view all the answers
What defines an address space in computing?
What defines an address space in computing?
Signup and view all the answers
How do linear address spaces differ from segmented address spaces?
How do linear address spaces differ from segmented address spaces?
Signup and view all the answers
What is a characteristic of segmented address spaces?
What is a characteristic of segmented address spaces?
Signup and view all the answers
Which of the following statements about virtual address spaces is true?
Which of the following statements about virtual address spaces is true?
Signup and view all the answers
Which of the following best describes a linear address?
Which of the following best describes a linear address?
Signup and view all the answers
What can be said about the relationship between virtual and physical addresses?
What can be said about the relationship between virtual and physical addresses?
Signup and view all the answers
In which instance would a segmented address space typically be used?
In which instance would a segmented address space typically be used?
Signup and view all the answers
What is the primary function of a memory management unit in a virtual memory system?
What is the primary function of a memory management unit in a virtual memory system?
Signup and view all the answers
What happens during a page fault in a paged system?
What happens during a page fault in a paged system?
Signup and view all the answers
How does page eviction help simulate extra memory?
How does page eviction help simulate extra memory?
Signup and view all the answers
In a paged system, what role do page tables play?
In a paged system, what role do page tables play?
Signup and view all the answers
Which of the following statements about virtual memory is false?
Which of the following statements about virtual memory is false?
Signup and view all the answers
What is a key characteristic of how pages are handled in a paged system?
What is a key characteristic of how pages are handled in a paged system?
Signup and view all the answers
What occurs after a page is evicted in the paging process?
What occurs after a page is evicted in the paging process?
Signup and view all the answers
Which of the following best describes paging in the context of virtual memory?
Which of the following best describes paging in the context of virtual memory?
Signup and view all the answers
Study Notes
Virtual Memory Overview
- Virtual memory is a system mechanism that separates program address space from physical memory layout.
- Virtual addresses represent locations within a program's address space.
- Physical addresses represent locations in actual hardware RAM.
- Virtual memory allows these two address spaces to be different.
Process Layout
- Each process has unmapped memory near NULL.
- Processes can potentially access the entire address space.
- Each process is denied access to memory used by other processes.
- Virtual memory resolves the apparent contradiction.
- Every address in a process's address space is a virtual address.
Physical Layout
- Hardware RAM layout varies significantly between machines and platforms.
- Certain memory locations may be restricted.
- Devices may appear within the memory address space.
- Different RAM amounts may be present.
- Historically, programs needed to be aware of these restrictions.
- Today, virtual memory hides these details from programs.
- The kernel must still be aware of the physical layout.
Memory Management Unit (MMU)
- The MMU translates addresses.
- It uses a per-process mapping structure to change virtual addresses to physical addresses.
- The MMU is hardware between the CPU and memory bus.
- Address translation needs to be very fast, but occasional performance penalties are possible.
- Kernel and hardware need to tightly integrate for translation management.
Paging
- Multiple virtual memory models are possible.
- x86-64 architectures support several models.
- Linux on x86-64 uses paging.
- Paging divides memory into fixed-sized pages.
- Multiple page sizes might exist in a system.
- Page sizes are typically powers of two.
- x86-64 small pages are 4 KB.
Page Metadata
- Page table metadata describes page features like readability/writability, code execution permission, and presence in memory.
- A page fault occurs when a memory access violates this metadata (e.g., write to a non-writable page).
- The MMU notifies the processor.
- The processor jumps to a specific kernel routine for processing.
- The kernel tries fixing the problem or informing the offending process.
Page Backing
- Virtual pages can use files, physical pages, or both for backing.
- A backed page's contents depend on its backing.
- Backed pages don't always need to be in memory.
- Clean pages are identical to their backing; dirty pages are different.
- Clean pages can be recreated from their backing at any time.
Demand Paging
- A virtual page might have backing but not be present in memory.
- Such pages are marked "not present" in page tables.
- Attempts to access these pages notify the kernel. (This is a page fault.)
- The kernel pages in the page by: finding an unused physical page, locating the virtual page's backing, reading the backing data into the physical page.
Demand Paging Benefits
- Physical memory allocation is quicker, simply by updating page tables.
- Executable file loading is faster; pages are marked present but backed by files.
- Accessing these pages causes the file to be read into memory.
- Unused pages are never loaded.
Program Break
- Calling
brk()
orsbrk()
changes a process's memory map. - Pages adjacent to the old program break are marked as "Not present, Readable and writable".
- This only affects page table metadata; the pages themselves aren't allocated.
- On a new page request, the MMU notifies the processor.
- The kernel locates and clears an unused page.
- The kernel adds the new page to the process's page table.
Moving the Program Break (Page Fault)
- The process's access to new pages is handled normally after the program break is moved.
- The MMU notifies the kernel when the process tries to access the new page.
- The kernel allocates the requested page.
C Stack
- The kernel manages the program stack.
- The stack grows as needed (not explicitly sized by the program).
- The kernel configures the MMU to manage the program stack.
- Similar to newly allocated memory, the kernel determines the stack size.
- Stack pages are marked "not present" but "readable and writable"
Page Eviction
- When memory is low, the system can evict a page.
- Clean pages are removed from the map.
- Dirty pages are written to their backing before removal.
- Swap space can back un-backed dirty pages.
- This allows the system to simulate more memory than physically available.
Address Spaces Summary
- Virtual memory uses a memory management unit.
- The CPU operates in a virtual address space separate from physical memory.
- The MMU translates virtual addresses to physical addresses.
- Paging divides both virtual and physical address spaces into pages.
- Pages can be individually mapped between virtual and physical addresses.
- Page tables allow the MMU to translate addresses.
- Page faults handle situations where mapped pages may not be currently allocated in physical memory.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz explores the concepts of virtual memory, focusing on the distinction between virtual and physical addresses. It covers the layout of processes and hardware RAM, including access restrictions and the importance of virtual memory in modern programming. Test your understanding of how virtual memory manages address spaces.