Podcast
Questions and Answers
What type of addressing do most modern machines use?
What type of addressing do most modern machines use?
- Indexed addressing
- Word addressing
- Byte addressing (correct)
- Segment addressing
What is the function of the MMU in address translation?
What is the function of the MMU in address translation?
- It converts virtual addresses to physical addresses. (correct)
- It generates random addresses for virtual space.
- It allocates memory to programs.
- It removes the need for a physical address space.
Which architecture uses paging in its virtual memory model?
Which architecture uses paging in its virtual memory model?
- ARM architecture
- x86-32 architecture
- x86-64 architecture (correct)
- PowerPC architecture
In a word-addressed machine, how is address 0x1 interpreted?
In a word-addressed machine, how is address 0x1 interpreted?
What does paging in virtual memory involve?
What does paging in virtual memory involve?
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?
How does demand paging improve the loading of executable files?
How does demand paging improve the loading of executable files?
What happens when brk() or sbrk() is called in a process?
What happens when brk() or sbrk() is called in a process?
What is a key benefit of demand paging related to memory allocation?
What is a key benefit of demand paging related to memory allocation?
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?
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?
How does the kernel manage the program stack during process creation?
How does the kernel manage the program stack during process creation?
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?
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?
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'?
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?
Which method describes the process of removing a dirty page from memory?
Which method describes the process of removing a dirty page from memory?
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?
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?
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?
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?
What function is called by the program to adjust the program break?
What function is called by the program to adjust the program break?
What happens to the new page after the break is moved?
What happens to the new page after the break is moved?
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?
In the context of page faults, what does 'unmapped' signify?
In the context of page faults, what does 'unmapped' signify?
Regarding page tables, what role do they play in memory management?
Regarding page tables, what role do they play in memory management?
What is required for managing translation mappings effectively?
What is required for managing translation mappings effectively?
What defines an address space in computing?
What defines an address space in computing?
How do linear address spaces differ from segmented address spaces?
How do linear address spaces differ from segmented address spaces?
What is a characteristic of segmented address spaces?
What is a characteristic of segmented address spaces?
Which of the following statements about virtual address spaces is true?
Which of the following statements about virtual address spaces is true?
Which of the following best describes a linear address?
Which of the following best describes a linear address?
What can be said about the relationship between virtual and physical addresses?
What can be said about the relationship between virtual and physical addresses?
In which instance would a segmented address space typically be used?
In which instance would a segmented address space typically be used?
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?
What happens during a page fault in a paged system?
What happens during a page fault in a paged system?
How does page eviction help simulate extra memory?
How does page eviction help simulate extra memory?
In a paged system, what role do page tables play?
In a paged system, what role do page tables play?
Which of the following statements about virtual memory is false?
Which of the following statements about virtual memory is false?
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?
What occurs after a page is evicted in the paging process?
What occurs after a page is evicted in the paging process?
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?
Flashcards
Virtual Address
Virtual Address
The address used by a process to access memory. This is not the actual physical address of the memory location.
Physical Address
Physical Address
The actual physical address of a memory location in RAM.
Memory Management Unit (MMU)
Memory Management Unit (MMU)
A mechanism within the CPU that translates virtual addresses into physical addresses. The CPU accesses memory through the MMU's address translations.
Paging
Paging
In virtual memory, the entire memory space is divided into equal-sized blocks called pages. These pages can be used to store data.
Signup and view all the flashcards
Address Translation
Address Translation
The process of converting a virtual address into a physical address.
Signup and view all the flashcards
Page Fault
Page Fault
A situation where the CPU attempts to access a page that is not currently present in physical memory.
Signup and view all the flashcards
Demand Paging
Demand Paging
A technique where pages are only loaded into memory when they are actually needed, reducing memory usage and improving program loading times.
Signup and view all the flashcards
brk() or sbrk()
brk() or sbrk()
A system call that modifies the memory map of a process, expanding its available memory space. This doesn't allocate physical memory immediately, but simply marks the new pages as potentially usable.
Signup and view all the flashcards
Page Table
Page Table
A type of metadata that specifies the physical location of a virtual page in physical memory. It is updated when pages are loaded into or removed from memory.
Signup and view all the flashcards
Address space
Address space
A range of potentially valid memory locations in a computer system.
Signup and view all the flashcards
Linear address
Linear address
Addresses in an address space that can be accessed directly without any indirection or translation. Each address corresponds to a unique location.
Signup and view all the flashcards
Segmented address space
Segmented address space
A type of address space where addresses are divided into two or more parts: a segment identifier and an offset within that segment. Each segment can be a linear address space.
Signup and view all the flashcards
Virtual Memory
Virtual Memory
A mechanism used by operating systems to manage memory. It allows programs to access more memory than physically available, by swapping pages of memory between physical memory and disk.
Signup and view all the flashcards
Virtual address space
Virtual address space
The set of all possible memory addresses available to a program or process in a computer system. It can be larger than the amount of physical memory available.
Signup and view all the flashcards
Moving the Program Break
Moving the Program Break
Moving the program break is a technique used by processes to allocate new memory space. It is implemented through a system call like sbrk() and typically triggers a Page Fault.
Signup and view all the flashcards
Kernel's Role in Page Fault
Kernel's Role in Page Fault
The kernel's role in a page fault is to locate a free page in physical memory, clear the content of that page, update the page table of the process, and inform the MMU about the change.
Signup and view all the flashcards
Not Present
Not Present
A state within the page table to mark a page as unavailable for immediate access. It indicates that the page needs loading from secondary storage into physical memory before it can be used.
Signup and view all the flashcards
Unmapped
Unmapped
A region of memory that remains unmapped in the page table, meaning it is not currently allocated to any process.
Signup and view all the flashcards
Page Eviction
Page Eviction
When an operating system chooses a page to remove from memory, often writing it to secondary storage (like a hard drive).
Signup and view all the flashcards
Swap
Swap
A special memory region used to store temporarily evicted pages from main memory. Swaps function as a secondary storage for pages that are not immediately needed but may be required later.
Signup and view all the flashcards
Program Break
Program Break
A mechanism used to dynamically allocate memory to a process. It involves setting a program break pointer in virtual memory, indicating the current end of the process's memory space. As the process requires more memory, the break pointer is moved.
Signup and view all the flashcards
Stack
Stack
A special memory region used by the process for temporary data storage. It is managed dynamically and automatically grows as needed to store function call information.
Signup and view all the flashcards
How does a Page Fault occur?
How does a Page Fault occur?
When a process requests to access a page, its virtual memory address is translated to a physical memory address via the page table. However, if the page is not present in the table, a fault occurs (page fault). This usually occurs if the program is trying to access memory that is not yet allocated or has been revoked.
Signup and view all the flashcardsStudy 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.