producer: while True: queue.lock() while (queue.isFull()): queue.unlock() queue.lock() queue.append(task) queue.unlock()
consumer: while True: queue.lock() while (queue.isEmpty()): queue.unlock() queue.lock() task = queue.pop() doStuff(task) queue.unlock()
du | sort -n
pthread_join
producer: while True: queue.lock() while (queue.isFull()): queue.unlock() wait(fullCV) # Sleep queue.lock() queue.append(task) signal(emptyCV) queue.unlock()
consumer: while True: queue.lock() while (queue.isEmpty()): queue.unlock() wait(emptyCV) # Sleep queue.lock() task = queue.pop() signal(fullCV) doStuff(task) queue.unlock()