桌子上有一空盘,允许放一只水果,爸爸可向盘子里放苹果,妈妈向盘子里放橘子。儿子

2020-10-28 教育 125阅读
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| 评论
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com