Machine-translated by Google. Questions are authored in English.
Top

Discussion

Memory-mapped file input and output means that

  • A.a file is mapped into the address space and accessed as if it were memory
  • B.files are stored in RAM instead of on disk
  • C.memory contents are printed to a file
  • D.the file system is kept in the page table

Answer: D

Correct answer: a file is mapped into the address space and accessed as if it were memory

Memory mapping associates a region of a process’s address space with a file on disk. Reading or writing that memory reads or writes the file, with the paging system doing the transfer as ordinary page faults. The advantage is that the usual read and write system calls disappear, and with them a copy: normally data moves from disk to a kernel buffer and then to the process’s buffer, whereas a mapped file is paged straight into the process’s own frames. For a file accessed repeatedly or randomly, that is substantially faster. It also provides shared memory between processes almost for free: two processes mapping the same file share the physical frames, and a write by one is visible to the other. Writes are not necessarily immediate - the operating system may defer them until the page is evicted or the file is closed - so an explicit synchronisation call exists where durability matters. Shared libraries are loaded this way, which is how one copy serves every process.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.