Buffer size used for FIFOS
Justin T. Gibbs
Fri Dec 29 16:55:00 GMT 2006
I have an application (Berkeley make) that manages parallelism using
a FIFO. The FIFO acts as a pool for "work tokens". All processes,
including the first that opens and "primes" the FIFO, must obtain a
token from the FIFO before performing a job and return that token when
the job is complete. Priming the FIFO entails writing N (number of
concurrent jobs) 1 byte tokens into the FIFO. The only problem with
this scheme is that it relies on the system having a PIPE_BUF value >= N,
and FIFOs that honor this value. Otherwise the tokens aren't guaranteed
to fit in the FIFO.
In playing with this in cygwin, I quickly discovered that the named pipes
used to implement FIFOs are created with a size of 1 byte. This is far less
than cygwin's PIPE_BUF (4096) or the POSIX mandated minimum for PIPE_BUF (512).
After reviewing the code, the setting seems deliberate
(fhandler_pipe::create_selectable() has an explicit check to avoid bumping the
size up to PIPE_BUF for FIFOs), but I couldn't find any code comments or
changelog entries to explain the restriction. Can anyone explain the
requirement for this limit? My limited testing (large parallel builds) after
recompiling the cygwin DLL from CVS with the value bumped up to 512, has shown
no ill effects.
More information about the Cygwin-developers