[lug] named pipe missunderstanding

Anthony Foiani tkil at scrye.com
Tue Feb 1 21:14:35 MST 2011


Jason --

Jason Davis <jdavis at openactive.org> writes:

> I say reads and what i really mean is an open/close cycle of the
> fifo.  A writer connecting, writting some data, then disconnecting.
> Each time this happens I incremented a variable. I'll try to be more
> clear =D

If the two processes are in perfect lock-step, then the numbers should
be the same.

On the other hand, if you're running both of them at full throttle,
then scheduling quanta could cause issues.  Consider:

  Task 1              Task 2
  ------              ------
                      wait on fifo read
  open fifo
  write data
                      start data read
  close fifo
  open fifo
  write data
                      finish data read
                      check for eof
                      start data read 
  close fifo
  open fifo
  write data
  close fifo
  open fifo
  write data
  ...

I'm not entirely sure, but I'm pretty sure there can be any number of
open / write / close cycles by task 1 during any single read by task
2, limited only by the pipe buffer within the kernel.

Task 2 will only detect EOF if (1) there is no more data to be read,
and (2) no process has the pipe open for write.

Perfectly willing to be corrected by anyone, though.  Jon, have you
ever gone digging in this section of the kernel?

HTH,
t.



More information about the LUG mailing list