Next: Use of dispatchers in
Up: Rationale on Dispatchers and
Previous: Flow handles.
Copying packets is one of the operations
dispatcher routines cannot do. However, a packet may be presented
to--and accepted by--multiple flow handles, each requiring its own
writable copy of the data. As mentioned above, the first accepting
flow handle exchanges its free buffer with the system buffer in which
the packet was received. The second and all subsequent handles will
also dequeue buffers off their free queues. These buffers, however,
are then declared dependent on the original buffer containing
the data. Each dependent buffer keeps track of its original buffer,
and each buffer containing an original copy of the data keeps track
of its dependents in a singly linked list. Before a write or map operation
can be performed on the buffer, it must be made ``independent.'' There are
two cases: for a dependent buffer, this involves copying the data from
the master copy into its own memory and removing this buffer from the
list of dependents. For a master copy with dependents, it involves
copying the data to the first dependent, which is then declared the
master for the remaining dependents. It can be seen that copying the
data can always be postponed to a context where the time spent copying
is accounted for. The scheme is slightly unfair in that it benefits
the thread picking up the last copy from a set of dependent buffers.
It avoids, however, the problems associated with computing the costs
of sharing buffers. Read operations on the buffer do not require
dependent buffers to be made independent because the data can be copied
directly from the master source.
Jay Lepreau
Tue Jun 2 05:48:49 MDT 1998