Memory-Mapped I/O
Memory-mapped I/O uses the same address space to address both main memory and I/O devices.
- Reads/writes to those addresses are interpreted as commands to that device
- When the processor issues the address and data, the memory system ignores it since that region is mapped to I/O. The address encodes the device identity and type of transmission.
A memory-mapped file is a segment of virtual memory that has been assigned a direct byte-for-byte correlation with some portion of a file.
Benefits:
- Orders of magnitude faster than system calls
- Input can be “cached” in RAM memory (page/file cache)
- A file requires disk access only when a new page boundary is crossed
- Memory-mapping may bypass the page/swap file completely
- Load and store raw data (no parsing/conversion)
I'm confused, what is the alternative?
The alternative is the standard IO operations, where you
read()orwrite()from IO, which is a System Call.