. NAMED PIPES (FIFOS - FIRST IN FIRST OUT)
reason at all. The entire operation occurs at once. The POSIX standard dictates in
/usr/include/posix1 lim.h that the maximum buffer size for an atomic operation on a pipe
is:
#define _POSIX_PIPE_BUF 512
Up to 512 bytes can be written or retrieved from a pipe atomically. Anything that
crosses this threshold will be split, and not atomic. Under Linux, however, the atomic
operational limit is defined in “linux/limits.h” as:
#define PIPE_BUF 4096
As you can see, Linux accommodates the minimum number of bytes required by
POSIX, quite considerably I might add. The atomicity of a pipe operation becomes important
when more than one process is involved (FIFOS). For example, if the number of
bytes written to a pipe exceeds the atomic limit for a single operation, and multiple processes
are writing to the pipe, the data will be “interleaved” or “chunked”. In other words,
one process may insert data into the pipeline between the writes of another.
Atomic Operations with Pipes
In order for an operation to be considered “atomic”, it must not be interrupted for anyreason at all. The entire operation occurs at once. The POSIX standard dictates in
/usr/include/posix1 lim.h that the maximum buffer size for an atomic operation on a pipe
is:
#define _POSIX_PIPE_BUF 512
Up to 512 bytes can be written or retrieved from a pipe atomically. Anything that
crosses this threshold will be split, and not atomic. Under Linux, however, the atomic
operational limit is defined in “linux/limits.h” as:
#define PIPE_BUF 4096
As you can see, Linux accommodates the minimum number of bytes required by
POSIX, quite considerably I might add. The atomicity of a pipe operation becomes important
when more than one process is involved (FIFOS). For example, if the number of
bytes written to a pipe exceeds the atomic limit for a single operation, and multiple processes
are writing to the pipe, the data will be “interleaved” or “chunked”. In other words,
one process may insert data into the pipeline between the writes of another.
No comments:
Post a Comment