This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Buffer size used for FIFOS


Would a sample program illustrating the failure increase interest
in this problem?  If so, I'd be happy to put something together.

--
Justin

Justin T. Gibbs wrote:
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.


Thanks,
Justin




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]