Buffer buffer .... // only accessed by operations push/pull Semaphore num = 0; // synchronization of consumers/producers Semaphore bufferAccess = 1; // critical region: buffer access // Producer: while (true) { newdata = produce(); P(bufferAccess); push(newdata,buffer); V(bufferAccess); V(num); } // Consumer: while (true) { P(num); P(bufferAccess); mydata = pull(buffer); V(bufferAccess); consume(mydata); }