Could anyone send me into the right direction ? Thanks !!
This is the code:
Expand|Select|Wrap|Line Numbers
- int itemCount
- procedure producer() {
- while (true) {
- item = produceItem()
- if (itemCount == BUFFER_SIZE) {
- sleep()
- }
- putItemIntoBuffer(item)
- itemCount = itemCount + 1
- if (itemCount == 1) {
- wakeup(consumer)
- }
- }
- }
- procedure consumer() {
- while (true) {
- if (itemCount == 0) {
- sleep()
- }
- item = removeItemFromBuffer()
- itemCount = itemCount - 1
- if (itemCount == BUFFER_SIZE - 1) {
- wakeup(producer)
- }
- consumeItem(item)
- }
- }