CS FundamentalsHardAccenture · Capgemini pattern
Memory-mapped files (via mmap) let a process treat a file's contents as part of its address space. Compared to read()/write() calls, what is the main advantage for random access to a large file?
- A. The OS can page in only the parts of the file actually touched (via demand paging), and repeated access avoids a system call and an extra buffer copy on every read
- B. mmap works only for files smaller than one page
- C. mmap removes the need for any page table entries
- D. mmap always loads the entire file into memory immediately, so it is simpler for the OS
Correct answer: A. The OS can page in only the parts of the file actually touched (via demand paging), and repeated access avoids a system call and an extra buffer copy on every read
mmap maps file pages into the address space lazily; accessing an unmapped region faults it in via the normal demand-paging machinery, and subsequent reads/writes are just memory accesses — no per-access system call or copy between a kernel buffer and user buffer, which read()/write() otherwise pay for on every call.
More Operating Systems questions
- Swap space (backing store) on disk lets the OS support more processes than fit entirely in physical RAM. Which statement about it is…
- RAID 5 stripes data across N disks and stores a rotating parity block (the XOR of the corresponding data blocks) on a different disk for…
- An array has 5 disks in RAID 5 (4 data + 1 rotating parity per stripe, effectively). Compared to plain striping (RAID 0) across the same 5…
- A disk subsystem uses C-LOOK (like C-SCAN, but it jumps straight to the lowest pending request instead of running all the way to the…
- In the standard five-state process model, which transition can NEVER happen directly?
- The data structure in which the OS keeps a process's program counter, register contents, state and open-file list is called the: