begin
S, SP,SO:semaphore;
S:=1;SP:=0;SO:=0;
cobegin
process father
begin
L1:have an apple;
P(S);
put an apple;
V(SP);
go to L1
end;
process mother
begin
L2:have an orange;
V(So);
go to L2
end;
process son
begin
L3:P(SO);
get an orange;
V(S);
eat an orange;
go to L3
end;
process daughter
begin
L4:P(SP);
get an apple;
V(S);
eat an apple;
go to L4
end;
coend;
end;赞同0| 评论