Is it possible to have pipe and multiple processes writing into the pipe and another process have to read from the pipe the entire data being written by the writing processes in single read() operation..?
Printable View
Is it possible to have pipe and multiple processes writing into the pipe and another process have to read from the pipe the entire data being written by the writing processes in single read() operation..?
I think with a named pipe it is possible. You have to use some synchonization mechanism to avoid read/write errors. The mechanism used are system dependent (i.e, whether you use Windows or any UNIx variant)
as per my knowledge fifo manages its own synchronisation for writing to it.
Issue is one process is writing asynchronously to it at oe end. Other process reading from other end periodically or asynchronuyously.
Now how this reader will become awar some data is being made available and how mcuh data is available, when that finishes reading
Well, I would create a named mutex object and then hold it until I write something. After the write process was finished, I would release the mutex object which blocks the reader. So the reader is now ready to read from read end of the pipe.
Honestly, I used such a mechanism in Windows but never used in UNIX.
i will also this method with 2 related processes or wwith threads. But in this case of fifo.My processes may not be related. So how i will come to know which process when is holding mutex.
Can i do sth with fcntl system call. Has anyone done such work?