A message pipe is a two-way communication channel between Xenomai tasks and standard Linux processes using regular file I/O operations on a pseudo-device. Pipes can be operated in a message-oriented fashion so that message boundaries are preserved, and also in byte streaming mode from real-time to standard Linux processes for optimal throughput.
Xenomai tasks open their side of the pipe using the rt_pipe_create() service; standard Linux processes do the same by opening one of the /dev/rtpN special devices, where N is the minor number agreed upon between both ends of each pipe. Additionally, named pipes are available through the registry support, which automatically creates a symbolic link from entries under /proc/xenomai/registry/native/pipes/ to the corresponding special device file.
Files | |
file | pipe.c |
This file is part of the Xenomai project. | |
Functions | |
int | rt_pipe_create (RT_PIPE *pipe, const char *name, int minor, size_t poolsize) |
Create a message pipe. | |
int | rt_pipe_delete (RT_PIPE *pipe) |
Delete a message pipe. | |
ssize_t | rt_pipe_receive (RT_PIPE *pipe, RT_PIPE_MSG **msgp, RTIME timeout) |
Receive a message from a pipe. | |
ssize_t | rt_pipe_read (RT_PIPE *pipe, void *buf, size_t size, RTIME timeout) |
Read a message from a pipe. | |
ssize_t | rt_pipe_send (RT_PIPE *pipe, RT_PIPE_MSG *msg, size_t size, int mode) |
Send a message through a pipe. | |
ssize_t | rt_pipe_write (RT_PIPE *pipe, const void *buf, 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 (RT_PIPE *pipe, size_t size) |
Allocate a message pipe buffer. | |
int | rt_pipe_free (RT_PIPE *pipe, RT_PIPE_MSG *msg) |
Free a message pipe buffer. |
|
Allocate a message pipe buffer. This service allocates a message buffer from the pipe's heap which can be subsequently filled by the caller then passed to rt_pipe_send() 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. |
|
Create a message pipe. This service opens a bi-directional communication channel allowing data exchange between Xenomai tasks and standard Linux processes. Pipes natively preserve message boundaries, but can also be used in byte stream mode from Xenomai tasks to standard Linux processes. rt_pipe_create() always returns immediately, even if no Linux process has opened the associated special device file yet. On the contrary, the non real-time side could block upon attempt to open the special device file until rt_pipe_create() is issued on the same pipe from a Xenomai task, unless O_NONBLOCK has been specified to the open(2) system call.
Environments: This service can be called from:
Rescheduling: possible. |
|
Delete a message pipe. This service deletes a pipe previously created by rt_pipe_create(). Data pending for transmission to non real-time processes are lost.
Environments: This service can be called from:
Rescheduling: possible. |
|
Flush the pipe. This operation makes the data available for reading from the associated special device.
Environments: This service can be called from:
Rescheduling: possible.
|
|
Free a message pipe buffer. This service releases a message buffer returned by rt_pipe_receive() to the pipe's heap.
This service can be called from:
Rescheduling: never. |
|
Read a message from a pipe. This service retrieves the next message written to the associated special device in user-space. rt_pipe_read() always preserves message boundaries, which means that all data sent through the same write(2) operation to the special device will be gathered in a single message by this service. This services differs from rt_pipe_receive() in that it copies back the payload data to a user-defined memory area, instead of returning a pointer to the internal message buffer holding such data. 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.
|
|
Receive a message from a pipe. This service retrieves the next message written to the associated special device in user-space. rt_pipe_receive() always preserves message boundaries, which means that all data sent through the same write(2) operation to the special device will be gathered in a single message by this service. This service differs from rt_pipe_read() in that it returns a pointer to the internal buffer holding the message, which improves performances by saving a data copy to a user-provided buffer, especially when large messages are involved. 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.
|
|
Send a message through a pipe. This service writes a complete message to be received from the associated special device. rt_pipe_send() 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 from the special device. This service differs from rt_pipe_write() in that it accepts a canned message buffer, instead of a pointer to the raw data to be sent. This call is useful whenever the caller wants to prepare the message contents separately from its sending, which does not require to have all the data to be sent available at once but allows for incremental updates of the message, and also saves a message copy, since rt_pipe_send() deals internally with message buffers.
Environments: This service can be called from:
Rescheduling: possible. |
|
Stream bytes to a pipe. This service writes a sequence of bytes to be received from the associated special device. Unlike rt_pipe_send(), this service does not preserve message boundaries. Instead, an internal buffer is filled on the fly with the data, which will be consumed as soon as the receiver wakes up. 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 from the associated special device. 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 from the special device. This service differs from rt_pipe_send() in that it accepts a pointer to the raw data to be sent, instead of a canned message buffer. This call is useful whenever the caller does not need to prepare the message contents separately from its sending.
Environments: This service can be called from:
Rescheduling: possible. |