Information Technology Reference
In-Depth Information
Figure 2. Dual π-channel behaviours: (a) when reader-to-writer link is available; and (b) during a
link failure, writer continues transmitting data to the space, delivery to the reader resumes upon link
restoration.
THE Π-CHANNEL API
3. int pi_read(int d, ptr b, int len, dtype_t 1 t):
reads a segment of len elements of type t
into buffer b from the descriptor d, blocks
if no segments are available. It returns the
number of elements successfully read or -1
if end of the pipe is reached.
4. int pi_write(int d, ptr b, int len, dtype_t t):
writes a segment of len elements of type t
from buffer b into the descriptor d.
5. int pi_close(int d), int pi_detach(int d): closes
the “write” and “read” end of the π-channel
d, respectively.
6. int pi_seek(int d, int seg_id): moves the logi-
cal pipe pointer for d to start reading from
segment seg_id, with 0 as the first segment.
This only works at the read end. On success,
it returns 0.
7. pi_tell(int d): returns the segment ID of the
logical pipe pointer of the π-channel.
The π-channels programming interface consists
of the following:
1. pi_attach(str n, int s): attaches to a π-channel
with name n on space s, does not block even if
π-channel is absent. It initiates asynchronous
receive, allowing segments to be buffered
locally even before the pi_read() is issued.
This primitive returns a descriptor represent-
ing the “read” end.
2. int pi_create(str n, int s, int mode): creates
a π-channel with name n on space s. The
mode argument is used to specify if this is a
CREATE - for new π-channels; or APPEND
- to resume writing. On success, it returns
a descriptor representing the “write” end of
the created π-channel.
Table 1. A brief overview of the key π-channels primitives
π-channel Primitive
Brief Description
pi_create()
Creates a new π-channel.
pi_attach()
Attach and retrieve a given π-channel.
pi_write()
Writes a pipe segment.
pi_read()
Reads a pipe segment.
pi_seek()
Seek to a new read segment position.
pi_tell()
Return the segment ID of upcoming segment.
pi_close()
Closes a π-channel that is opened for writing.
pi_detach()
Detach from reading a π-channel.
pi_unlink()
Marks a closed π-channel for deletion.
 
Search WWH ::




Custom Search