O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Memory-Mapped Files

Memory-mapped files are a blend of the virtual memory system and the file system, where a file’s contents are mapped onto a range of bytes in memory. When you get bytes from that range of memory, you are actually reading from the file. When you change bytes in that range of memory, you are writing to the file. In essence, you are doing I/O without using read() and write(). The virtual memory system gets to do the work of buffering, reading, and writing, only bringing in the blocks from disk that are actually used. To use memory-mapped files, you need to open the file, then call

caddr_t mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset);

The return value is the address where the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required