Differences

This shows you the differences between two versions of the page.

disc:ver3 [2009/03/28 00:24]
gporter
disc:ver3 [2009/04/01 17:03] (current)
rfonseca
Line 23: Line 23:
  * I changed the items into ones that we are clear about (+), and others that are still speculations (s).   * I changed the items into ones that we are clear about (+), and others that are still speculations (s).
  * A clarification on the named pipes: the messages are atomic if they are smaller than a certain size (PIPE_BUF). However, I think we can't guarantee reliability, if the kernel buffers fill up we may end up losing messages.   * A clarification on the named pipes: the messages are atomic if they are smaller than a certain size (PIPE_BUF). However, I think we can't guarantee reliability, if the kernel buffers fill up we may end up losing messages.
 +---
 +More on Named Pipes
 +
 +According to Unix Network Programming Volume 2, Chapter 4
 +
 +  * Named pipe writes are atomic iff the size of the message is <= PIPE_BUF
 +  * To get the value of PIPE_BUF for a system, ''getconf PIPE_BUF <path>'', where path is a path to a file or directory.
 +    * On MacOS X 10.5.6, PIPE_BUF is 512
 +    * On RedHat Enterprise Linux 4 PIPE_BUF is 4096
 +  * They can be opened for reading OR writing, blocking or non-blocking
 +    * Opening for reading:
 +      * if open for writing, returns OK for blocking and non-blocking
 +      * if not open for writing, blocks if blocking, returns OK if non-blocking
 +    * Opening for writing:
 +      * if open for reading, returns OK for blocking and non-blocking
 +      * if not open for writing, blocks if blocking, returns error ENXIO if non-blocking
 +    * Reading empty FIFO:
 +      * if open for writing:
 +        * if blocking: blocks until there is data or the FIFO is closed for writing
 +        * if non-blocking: returns error EAGAIN
 +      * if not open for writing:
 +        * read returns 0 for blocking and non-blocking
 +    * Writing to FIFO:
 +      * if not open for reading:
 +        * SIGPIPE generated for thread. If not caught, this will cause the process to terminate. If the process ignores the signal, write returns an error of EPIPE. Best practice is to ignore the signal and deal with the error.
 +  * If the FIFO is open for reading and you write:
 +    * If the size is less than PIPE_BUF and there is room in the pipe: all bytes are transferred atomically
 +    * If the size is less than PIPE_BUF and there is no room: the process blocks if blocking and returns EAGAIN if non-blocking
 +    * If the size is more than PIPE_BUF, no atomicity guarantees:
 +      * If there is room for at least one byte in the buffer, kernel fills buffer and returns the size transferred
 +      * If there is no room, returns EAGAIN. Not clear what happens if blocking.
 +       
 
disc/ver3.txt · Last modified: 2009/04/01 17:03 by rfonseca
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki