The P
begin
var max_capacity=n
cobegin
process barber
begin
repeat;
p(cust_ready);
理發;
until false
end
process customer
begin
repeat;
p(max_capacity);//是否有空閒椅子
進入店裡
p(barber_chair);//是否有空閒的理發椅
坐在理發椅上
v(cust_ready);//喚醒理發師
p(finished);//是否完成理發
離開理發椅
v(leave_b_chair);
離開店
v(max_capacity);
until false
end
coend
end
[
From:http://tw.wingwit.com/Article/program/czxt/201311/24278.html