next up previous contents
Next: Performance Up: User Level IPC Previous: Producer   Contents

Consumer

The consumer as outlined in figure 49 sets a shared variable toRead to true in order to indicate its purpose for receiving data. This allows the producer to recognise that a consumer is waiting and to wake it up if it is blocked on the empty queue. Then the consumer checks rLength to find out if there are enough data ready to be received. It will block on a condition variable if the queue is empty. As soon as there are enough bytes to be read the variable toRead can be reset. There is no longer any need for the producer to try to wake up the consumer. Subsequently the consumer retrieves the data from the ring and transfers them to the user supplied buffer receiveBuffer. Finally the number of bytes received is subtracted from the shared variable that holds the amount of data in the queue. This access has to be mutually exclusive with respect to the producer. We achieve this by applying a user level algorithm.


\begin{Figure}
% latex2html id marker 1323\begin{tabbing}
\hspace*{3cm}\= \hsp...
...LevelUnlock();
\end{tabbing}\caption {
Pseudocode for the consumer.}\end{Figure}


next up previous contents
Next: Performance Up: User Level IPC Previous: Producer   Contents
Johannes Gutleber
1999-10-29