On Thursday, February 21, 2002, at 04:20 PM, john cooper wrote:
Realistically, mmap() is a luxury provided by virtual memory operating systems. As used my minimad it is a simple way to get the system to do the file I/O automatically under the hood, and simplifies the programming model. You will however find doing the stream I/O yourself to be lower overhead and more appropriate for the application environments where libmad is attractive.
Granted, without a virtual memory system, mmap() might not be the best or even a possible approach. However, it can have special benefits when available that make it more attractive than traditional I/O. Since mmap() usually provides direct access to memory pages from the filesystem's block cache, the overhead of additional private buffer space and memory copying is avoided. Eliminating the buffer for your own stream I/O can be important especially in low-memory environments, particularly since multiple instances can share memory-mapped pages.
On systems where the secondary data storage is already memory-accessible, such as flash devices, mmap() is an even more obvious choice.
-- Rob Leslie rob@mars.org