[LCP] Questions Regarding FIFO

Steve Baker ice at mama.indstate.edu
Wed Aug 8 13:25:31 UTC 2007


Ludwig Isaac Lim <ludz_lim at yahoo.com> wrote:
>    According to Linux man pages fifo(7), when processes
> exchange data using a fifo, the kernel passes all data
> internaly without writing to a file.
>
>    Supposing I have a "producer" process which passes data
> to "consumer" process using a fifo, and the consumer
> process is slower than the producer. Where does  the kernel
> store the unprocessed messages? Assuming the kernel stored
> it in the memory. Is there a limitation on the size of the
> "backlog"? Is there something like message queue's MSGMAX
> and MSGMNB parameters?

  When the producer produces more than the consumer processes, then it will
simply block on writing to the fifo/pipe, or in otherwords, stop writing, when
the pipe has become full.  That is unless O_NONBLOCK was set when the
fifo/pipe was opened, in which case it will write as much data as will fill
the pipe and then return with an EAGAIN error (in which case the producer will
need to re-write the data not written).

  Linux pipes are hardwired to be a single page in size (4096 bytes).  However
according to the man page (man 7 pipe), since kernel 2.6.11, fifo/pipes are
hardwired to 64K in size.  The fifo/pipe buffer size should be available in
the external define PIPE_BUF, but it seems to still be 4096 in all the kernel
sources > 2.6.11 that I have.

  Read the man pages on pipe and fifo in section 7 for more complete
information (ex: man 7 pipe fifo).

							- Steve



More information about the linuxCprogramming mailing list