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?
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.