PIP Module
Application Program Interface
2-267
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.
A pipe has two ends, as shown in Figure 2-7. The writer end (also called
the producer) is where your program writes frames of data. The reader
end (also called the consumer) is where your program reads frames of
data
Figure 2-7.
Pipe Schematic
Internally, pipes are implemented as a circular list; frames are reused at
the writer end of the pipe after PIP_free releases them.
The notifyReader and notifyWriter functions are called from the context
of the code that calls PIP_put or PIP_free. These functions can be written
in C or assembly. To avoid problems with recursion, the notifyReader and
notifyWriter functions normally should not directly call any of the PIP
module functions for the same pipe. Instead, they should post a SWI that
uses the PIP module functions. However, PIP calls may be made from
the notifyReader and notifyWriter functions if the functions have been
protected against re-entrancy.
Reader
Writer
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)