Message pipes are an improved replacement for the legacy RT-FIFOS. A message pipe is a two-way communication channel between a kernel-based real-time thread and a user-space process. Pipes can be operated in a message-oriented fashion so that message boundaries are preserved, and also in byte streaming mode from kernel to user-space for optimal throughput.
Kernel-based RTAI tasks open their side of the pipe using the rt_pipe_open() service; user-space processes do the same by opening the /dev/rtpN special devices, where N is the minor number agreed between both ends of each pipe.
Files | |
file | pipe.c |
This file is part of the RTAI project. | |
Functions | |
int | rt_pipe_open (RT_PIPE *pipe, int minor) |
Open a pipe. | |
int | rt_pipe_close (RT_PIPE *pipe) |
Close a pipe. | |
ssize_t | rt_pipe_read (RT_PIPE *pipe, RT_PIPE_MSG **msgp, RTIME timeout) |
Read a message from a pipe. | |
ssize_t | rt_pipe_write (RT_PIPE *pipe, RT_PIPE_MSG *msg, size_t size, int mode) |
Write a message to a pipe. | |
ssize_t | rt_pipe_stream (RT_PIPE *pipe, const void *buf, size_t size) |
Stream bytes to a pipe. | |
ssize_t | rt_pipe_flush (RT_PIPE *pipe) |
Flush the pipe. | |
RT_PIPE_MSG * | rt_pipe_alloc (size_t size) |
Allocate a message pipe buffer. | |
int | rt_pipe_free (RT_PIPE_MSG *msg) |
Free a message pipe buffer. |
|
Allocate a message pipe buffer. This service allocates a message buffer from the system heap which can be subsequently filled by the caller then passed to rt_pipe_write() for sending. The beginning of the available data area of size contiguous bytes is accessible from P_MSGPTR(msg).
This service can be called from:
Rescheduling: never. |
|
Close a pipe. This service closes a pipe previously opened by rt_pipe_open(). Data pending for transmission to user-space are lost.
Environments: This service can be called from:
Rescheduling: possible. |
|
Flush the pipe. This service flushes any pending data buffered by rt_pipe_stream(). The data will be immediately sent to the user-space side of the pipe.
Environments: This service can be called from:
Rescheduling: possible. |
|
Free a message pipe buffer. This service releases a message buffer returned by rt_pipe_read() to the system heap.
This service can be called from:
Rescheduling: never. |
|
Open a pipe. This service opens a bi-directional communication channel allowing data exchange between real-time tasks and regular user-space processes. Pipes natively preserve message boundaries, but can also be used in byte stream mode from kernel to user space. rt_pipe_open() always returns immediately, even if the user-space side of the same pipe has not been opened yet. On the contrary, the user-space opener might be suspended until rt_pipe_open() is issued on the same pipe from kernel space, unless O_NONBLOCK has been specified to open(2).
Environments: This service can be called from:
Rescheduling: never. |
|
Read a message from a pipe. This service retrieves the next message sent from the user-space side of the pipe. rt_pipe_read() always preserves message boundaries, which means that all data sent through the same write(2) operation on the user-space side will be gathered in a single message by this service. Unless otherwise specified, the caller is blocked for a given amount of time if no data is immediately available on entry.
Environments: This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
|
|
Stream bytes to a pipe. This service writes a sequence of bytes to be received by the user-space side of the pipe. Unlike rt_pipe_write(), this service does not preserve message boundaries. Instead, an internal buffer is filled on the fly with the data. The actual sending may be delayed until the internal buffer is full, or the Linux kernel is re-entered after the real-time system enters a quiescent state. Data buffers sent by the rt_pipe_stream() service are always transmitted in FIFO order (i.e. P_NORMAL mode).
Environments: This service can be called from:
Rescheduling: possible. |
|
Write a message to a pipe. This service writes a complete message to be received by the user-space side of the pipe. rt_pipe_write() always preserves message boundaries, which means that all data sent through a single call of this service will be gathered in a single read(2) operation on the user-space side.
Environments: This service can be called from:
Rescheduling: possible. |