I spawn many processes and I need each process to wait for input. Is creating a named pipe per process a good idea? Or should I consider some other way of synchronisation?
I know for certain that making a normal file for every separate process would be very bad since the processes would get slowed down by the hard disk. But how do named pipes compare in that regard? Are they as fast as signals or as slow as normal files?
A named pipe is just a file system entry for an in-memory buffer, so access should be fast enough.
I wouldn't avoid using a real file until you prove that it is a bottleneck. Since the OS will buffer small writes to a file in memory until either an attempt to read the file is made or the buffer fills up, you may not experience any I/O delay due to your hard drive's speed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With