












































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













































process
Producer
begin
loop
<produce
char
“c”>
BoundedBuffer.deposit(c) end
loop
end
Producer
process
Consumer
begin
loop
BoundedBuffer.remove(c) <consume
char
“c”>
end
loop
end
Consumer
monitor:
BoundedBuffer
var
buffer
nextIn, nextOut
entry
deposit(c:
char)
begin
end entry
remove(var
c:
char)
begin
end
end BoundedBuffer
monitor
BoundedBuffer
var
buffer
array[0..n-1]
of
char
nextIn,nextOut
0..n-
fullCount
0..n
notEmpty,
notFull
condition
entry
deposit(c:char)
entry
remove(var c:
char)
begin
begin
if
(fullCount
n)
then
if
(fullCount
n)
then
wait(notFull)
wait(notEmpty)
end
if
end
if
buffer[nextIn]
c
c
buffer[nextOut]
nextIn
nextIn+
mod
n
nextOut
nextOut+
mod
n
fullCount :=
fullCount+
fullCount
fullCount-
signal(notEmpty)
signal(notFull)
end
deposit
end
remove
end BoundedBuffer