in reply to buffering when reading from unnamed pipe with child process
After the fork you have two processes which each get slices of time in which to do some work. That means that the nature of that work is bursty - busy for a while, idle for a while - depending on what else is going on in the machine so for both producer and consumer the processing is in bursts and that is essentially out of the control of the processes. It's not the pipe that is introducing the burstiness through buffering, but it is a fundamental property of preemptive multi tasking operating systems.
You could introduce semaphores or mutexes to lock step the two processes, but then you probably lose the advantage of having two processes anyway.
Update: that might make sense if the OP didn't have a sleep generating output in bursts. See tybalt89's reply below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: buffering when reading from unnamed pipe with child process
by tybalt89 (Monsignor) on Nov 20, 2020 at 00:38 UTC |