Hardware Reference
In-Depth Information
10.6.2
CAB IMPLEMENTATION
The data structure used to implement a CAB is shown in Figure 10.17. A CAB con-
trol block must store the maximum number of buffers ( max buf ), their dimension
( dim buf ), a pointer to a list of free buffers ( free ), and a pointer to the most recent
buffer ( mrb ). Each buffer in the CAB can be implemented as a data structure with
three fields: a pointer ( next ) to maintain a list of free buffers, a counter ( use ) that
stores the current number of tasks accessing that buffer, and a memory area ( data ) for
storing the message.
The code of the four CAB primitives is shown below. Note that the main purpose of
the putmes primitive is to update the pointer to the most recent buffer (MRB). Before
doing that, however, it deallocates the old MRB if no tasks are accessing that buffer.
Similarly, the unget primitive decrements the number of tasks accessing that buffer
and deallocates the buffer only if no task is accessing it and it is not the MRB.
free
mrb
max_buf
dim_buf
next
next
NIL
use
use
use
use
reading task
most
recent
p
data
empty
empty
buffer
Figure 10.17
CAB data structure.
 
Search WWH ::




Custom Search