CS326 Project 04: Implementing mmap() in xv6
Practice Exam Problems
Easy Problems
Memory Mapping Basics What is the primary purpose of the shared memory implementation of mmap() in the xv6 operating system? Explain what functionality it provides.
Page Table Structure Describe the three-level page table structure used in xv6-RISC-V. What are the key components of a page table entry (PTE), and which permission bits are most relevant for shared memory?
System Call Interface What are the two system calls implemented for shared memory management in xv6? Describe the parameters and return values for each.
Memory Region Layout In the xv6 mmap implementation, where is the shared memory region located in the process address space? Why is this location chosen?
Physical Memory Management Explain how the system determines when to allocate or free the physical memory used for shared memory. What mechanism ensures memory is not freed prematurely?
Inter-Process Communication How does the shared memory implementation enable communication between a parent and child process? What happens during a fork() operation?
System Structure Name and briefly describe the key files that need to be modified to implement the mmap functionality in xv6.
Moderate Problems
Implementation Design How does the
shmem_page
structure track shared memory pages? List its fields and explain the purpose of each.Reference Counting Explain how reference counting is used in the mmap implementation. What happens when a process unmaps a shared memory region that is still in use by other processes?
Error Handling What are the possible failure points in the mmap() and munmap() functions? How does the implementation handle these potential failures?
Synchronization Why are locks necessary in the shared memory implementation? Identify the critical sections where race conditions might occur without proper synchronization.
Page Table Modification Explain how the implementation modifies the page tables to map the same physical page to multiple processes. Which function is used to add mappings to a page table?
Memory Cleanup What modifications are made to the process cleanup routines to properly handle shared memory? How does the system ensure that shared pages are only freed when they are no longer used?
Test Program Describe the steps the mmaptest program takes to verify that shared memory is working correctly. What specific functionality does it test?
Hard Problems
- Implementation Analysis The current implementation only supports a single shared memory page at a fixed address. Design an extension to the current implementation that would support multiple shared memory regions at dynamically determined addresses. What data structures would you need to modify or add?