0
0
Operating Systemsknowledge~5 mins

Memory-mapped files in Operating Systems - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a memory-mapped file?
A memory-mapped file is a file that is mapped into the memory address space of a process, allowing the file contents to be accessed like regular memory instead of using traditional file input/output operations.
Click to reveal answer
beginner
How does a memory-mapped file improve file access?
It allows programs to read and write files by directly accessing memory, which can be faster and more efficient than using read/write system calls because it reduces copying between user space and kernel space.
Click to reveal answer
intermediate
What happens when multiple processes map the same file into memory?
They can share the same physical memory pages, enabling efficient inter-process communication and data sharing without extra copying of data.
Click to reveal answer
intermediate
Name one risk or limitation of using memory-mapped files.
If the file is very large, mapping it entirely into memory can consume a lot of address space, and changes to the mapped memory might not be immediately saved to disk, risking data loss if the program crashes.
Click to reveal answer
intermediate
Explain the difference between memory-mapped files and traditional file I/O.
Traditional file I/O uses system calls to read or write data explicitly, copying data between disk and user memory. Memory-mapped files let the OS handle this by mapping file contents directly into memory, so programs can access files like arrays in memory.
Click to reveal answer
What is the main benefit of using memory-mapped files?
AAutomatically compresses files on disk
BFaster file access by treating file data as memory
CEncrypts files for security
DPrevents other processes from accessing the file
Which of the following is true about memory-mapped files?
AThey map file contents into a process's memory space
BThey require copying data between user and kernel space for every access
CThey only work with text files
DThey cannot be shared between processes
What can happen if a program modifies a memory-mapped file's memory region?
AThe changes may be delayed before being written to disk
BThe changes are immediately saved to disk without delay
CThe file becomes read-only
DThe file is deleted automatically
Memory-mapped files are especially useful for:
ASmall files only
BBacking up files
CSharing data between multiple processes
DEncrypting files
Which operating system feature supports memory-mapped files?
AUser authentication
BFile compression
CNetwork routing
DVirtual memory management
Describe what a memory-mapped file is and how it differs from traditional file reading and writing.
Think about how programs access file data in memory-mapped files versus normal file operations.
You got /4 concepts.
    Explain one advantage and one limitation of using memory-mapped files.
    Consider performance benefits and potential risks.
    You got /2 concepts.