Hardware Reference
In-Depth Information
are interested only in fresh sensory data rather than in the complete message history
produced by a sensory acquisition task.
CABs can be created and initialized by the open cab primitive, which requires speci-
fying the CAB name, the dimension of the message, and the number of messages that
the CAB may contain simultaneously. The delete cab primitive removes a CAB from
the system and releases the memory space used by the buffers.
To insert a message in a CAB, a task must first reserve a buffer from the CAB memory
space, then copy the message into the buffer, and finally put the buffer into the CAB
structure, where it becomes the most recent message. This is done according to the
following scheme:
buf pointer = reserve (cab id);
<copy message in *buf pointer>
putmes (buf pointer, cab id);
Similarly, to get a message from a CAB, a task has to get the pointer to the most recent
message, use the data, and release the pointer. This is done according to the following
scheme:
mes pointer = getmes (cab id);
<use message>
unget (mes pointer, cab id);
Note that more tasks can simultaneously access the same buffer in a CAB for reading.
On the other hand, if a task P reserves a CAB for writing while another task Q is
using that CAB, a new buffer is created, so that P can write its message without
interfering with Q .As P finishes writing, its message becomes the most recent one in
that CAB. The maximum number of buffers that can be created in a CAB is specified
as a parameter in the open cab primitive. To avoid blocking, this number must be
equal to the number of tasks that use the CAB plus one.
Search WWH ::




Custom Search