Data Pipe Manager (PIP Module)
6-8
6.4 Data Pipe Manager (PIP Module)
Pipes are designed to manage block I/O (also called stream-based or
asynchronous I/O). Each pipe object maintains a buffer divided into a fixed
number of fixed length frames, specified by the numframes and framesize
properties. All I/O operations on a pipe deal with one frame at a time.
Although each frame has a fixed length, the application can put a variable
amount of data in each frame (up to the length of the frame).
As shown in Figure 6-2, a pipe has two ends. The writer end is where the
program writes frames of data. The reader end is where the program reads
frames of data.
Figure 6-2. The Two Ends of a Pipe
Data notification functions (notifyReader and notifyWriter) are performed to
synchronize data transfer. These functions are triggered when a frame of
data is read or written to notify the program that a frame is free or data is
available. These functions are performed in the context of the function that
calls PIP_free or PIP_put. They can also be called from the thread that calls
PIP_get or PIP_alloc. When PIP_get is called, DSP/BIOS checks whether
there are more full frames in the pipe. If so, the notifyReader function is
executed. When PIP_alloc is called, DSP/BIOS checks whether there are
more empty frames in the pipe. If so, the notifyWriter function is executed.
A pipe should have a single reader and a single writer. Often, one end of a
pipe is controlled by an HWI and the other end is controlled by a software
interrupt function. Pipes can also be used to transfer data within the program
between two application threads.
During program startup (which is described in detail in section 2.8, DSP/BIOS
Startup Sequence, page 2-24), the BIOS_start function enables the
DSP/BIOS modules. As part of this step, the PIP_startup function calls the
notifyWriter function for each pipe object, since at startup all pipes have
available empty frames.
ReaderWriter
1. PIP_alloc
2. Writes data into allocated frame
3. PIP_put (runs notifyReader)
1. PIP_get
2. Reads data from frame just received
3. PIP_free (runs notifyWriter)