Hacker News new | ask | show | jobs
by maxidog 4239 days ago
Is that fundamentally different from http://en.wikipedia.org/wiki/Memory-mapped_file ?
1 comments

I was just thinking about this the other day. Yes, a memory-mapped-file is different, because the API is still that of a file. The memory mapping is just a behind-the-scenes optimisation.
Only if you want posix compliance across threads and such. If you just want the contents of the file memory mapped nothing stops you from setting up a shared memory segment and mapping it without that filesystem overhead.
Does that work for writes as well? I am not sure if it would work without the OS setting up traps for writes to the pages or explicit flush calls from the app. In the former case, it would be very inefficient, and in the latter, it wouldn't be a clean write-and-forget system.
Yes, it works for writes and support is built-in to current processors. It's faster than conventional file access.