On Fri, Nov 15, 2002 at 03:53:53PM -0500, Stephen Adkins wrote:
> At 02:09 PM 11/15/2002 -0500, Rocco Caputo wrote:
> >On Fri, Nov 15, 2002 at 11:45:33AM -0500, Stephen Adkins wrote:
> ....
> >> QUESTIONS:
> >> 
> >>  * What queue mechanism would you use, assuming all of the
> >>    writers and readers are on the same system?
> >>    (IPC::Msg? MsgQ?)
> >
> >If speed is a major factor, I would use a FIFO (named pipe).  This is
> >a very lightweight and fast way to pass data between processes on the
> >same machine.
> 
> Are FIFO's (named pipes) on Unix guaranteed to maintain the integrity
> of the messages in the case of multiple writers?
> I think you could guarantee this if you imposed restrictions on the
> data travelling through the pipe: i.e. single text line, must be
> written in a single (unbuffered) write() system call.
> Otherwise, doesn't a FIFO break down as a message queue when you have
> multiple writers with arbitrarily long message data?

According to _Advanced Programming in the UNIX Environment_, the
largest atomic write is PIPE_BUF bytes.  On FreeBSD,
/usr/include/limits.h defines PIPE_BUF as 512 bytes.

APUE also says:

  Indeed, the normal file I/O functions (close, read, write, unlink,
  etc.) all work with FIFOs.

This leads me to believe that flock() could protect the integrity of
large FIFO writes.  I've never had the occasion to need it and can't
say for sure.

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to