var mutex = 1 : semaphore ; {binary} space = N : semaphore ; cans = 0 : semaphore ; Process PRODUCER; loop {pick can off crate} P(space) ; {wait for slot in the coke machine} P(mutex) ; {get mutual exclusion} {put one can in machine} V(mutex} ; {release mutual exclusion} V(cans} ; {signal cans available} end ; Process CONSUMER; loop P(cans) ; {wait for any cans} P(mutex) ; {obtain mutual exclusion} {take one can} V(mutex) ; {release mutual exclusion} V(space) ; {signal space available} end ;