QuizzesMemory-Mapped I/O & Files — Concept Check
advanced
operating-systems

Memory-Mapped I/O & Files — Concept Check

Questions on Memory-Mapped I/O & Files. Memory-mapped files map file contents directly into a process's virtual address space, allowing file I/O to be performed as ordinary memory operations with OS-managed demand paging.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Memory-Mapped I/O & Files — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer is using Java's FileChannel.map() to handle a large file. They notice reduced performance when accessing random parts of the file. What is likely happening?

    • AThe file is not fully loaded into memory, causing frequent page faults.
    • BThe file is being copied twice, slowing down access.
    • CThe FileChannel.map() method is not suitable for large files.
    • DThe JVM heap is overloaded with file data.
  2. 2.Two processes use memory-mapped files for IPC. They experience sub-microsecond latency. Why is this possible?

    • AMemory-mapped files avoid kernel buffering, allowing direct memory access.
    • BMemory-mapped files use a dedicated high-speed network.
    • CThe processes use a special low-latency file system.
    • DThe OS prioritizes memory-mapped files for faster access.
  3. 3.A developer claims that using MappedByteBuffer in Java eliminates all system calls for file I/O. What is the flaw in this claim?

    • AMappedByteBuffer eliminates copying but not all system calls.
    • BMappedByteBuffer is only for small files, not large ones.
    • CMappedByteBuffer increases system calls due to page faults.
    • DMappedByteBuffer requires more system calls than FileInputStream.
  4. 4.A service using memory-mapped I/O for a database buffer pool sees high `si`/`so` in `vmstat`. What does this indicate?

    • AThe database buffer pool is too small, causing frequent disk reads.
    • BThe memory-mapped I/O is not functioning, leading to data loss.
    • CThe system is experiencing high swap activity due to memory pressure.
    • DThe service is not using memory-mapped I/O correctly, causing errors.
  5. 5.A developer uses FileInputStream.read() for file access and notices high CPU usage. What could be the reason?

    • AFileInputStream.read() is optimized for large files, not small ones.
    • BFileInputStream.read() directly maps files into memory, causing overhead.
    • CFileInputStream.read() requires copying data from kernel to user space.
    • DFileInputStream.read() uses memory-mapped I/O, causing CPU spikes.
  6. 6.Which Java API provides a safer alternative to MappedByteBuffer for memory-mapped files?

    • AMemorySegment (Foreign Memory API)
    • BRandomAccessFile
    • CFileInputStream.read()
    • DBufferedReader.readLine()
  7. 7.What is a key advantage of using memory-mapped files for large file processing?

    • AEnsures data is always loaded into RAM, improving speed.
    • BEliminates the need for double buffering, reducing memory usage.
    • CPrevents any page faults during file access.
    • DAutomatically compresses file data in memory.