File handling vs shared memory


In interprocess communication(IPC) when processe have to share data among each other,why cant they all connect to one single file and share data with help of basic file handling functions such as read and write?

Why do we need shared memory(shmget shmat(),shmdt()..etc) and mapped memory(mmap(),munmap()..etc) concepts?
Performance for one thing.
File access is very slow compared to memory. Also it tends to slow down depending on fragmentation/amount of seeking. Also it wears discs (most prominent for SSD). Also it is hard to prevent data races and other pitfalls of concurrent programming. It is impossible to use buffered output/input, destroing last bits of perfomance we have.
Since the file operation mostly take place in memory, performance is not that much of an issue.

So can do that, but since basic file handling is very limited it's hard to deal with.

By the way: Windows does memory mapping, pipes, etc. with file handles:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366878%28v=vs.85%29.aspx
Topic archived. No new replies allowed.