Producer-consumer work queues

 $$
However, this simple version does not account for the following possibilities:
1
The producer thread must not overwrite the shared buffer when the previous task has not been picked up by a consumer thread.
2
The consumer threads must not pick up tasks until there is something present in the shared data structure.
3
Individual consumer threads should pick up tasks one at a time.
 $$
To implement this, we can use a variable called task_available.

All of these operations on the variable task_available should be protected by mutex-locks to ensure that only one thread is executing test-update on it.

\includegraphics[scale=0.9]{figures/9-4}

\includegraphics[scale=0.9]{figures/9-5}

\includegraphics[scale=0.9]{figures/9-6}

Cem Ozdogan 2010-12-06