semaphore mutex=1;
semaphore empty=20;
semaphore full=0;
int in,out = 0;
item p [20];
void Producer(){
while(ture){
producer an item in nextp;
wait(empty);
wait(mutex);
p[in] := nextp;
in := (in+1) mod 20;
signal(mutex);
signal(full);
}
}
void Consumer(){
while(ture){
wait(full);
wait(mutex);
nextc := p[out];
out := (out+1) mod 20;
signal(mutex);
signal(empty);
}
}