文章
363
粉丝
0
获赞
0
访问
73.7k
semaphore mutex1=0,yi_bing=0,tong=1,qiao=1//定义互斥信号量使进程互斥访问hole,信号量yi_bing用来通知丙来进行浇水;信号量桶初值为1,信号量铁锹初值为1;
int hole=0;//未放入树的洞初值为0
P甲(){
while(true){
if(hole<3){
P(qiao);
挖洞;
v(qiao);
p(mutex);
hole++;
v(mutex);
}
}
p乙(){
while(true){
if(hole>0){
P(qiao);
放树;
填土;
V(qiao);
V(yi_bing);
P...
登录后发布评论
暂无评论,来抢沙发