文章
10
粉丝
0
获赞
0
访问
499
semaphore empty = 10; //表示缸还能装多少桶
semaphore full = 0; //表示缸已经装了多少桶
semaphore mutex1 = 1; //表示对井的互斥使用
semaphore mutex2 = 1; //表示对缸的互斥使用
semaphore pail = 3; //表示可用桶数
入水(){
while(1){
P(empty);
P(pail);
P(mutex1);
入井打水;
V(mutex1);
P(mutex2);
水入缸;
V(mutex2);
V(pail);
V(full);
}
}
取水(){
while(1){
P(full);
P(pail);
P(mutex2);
入缸取水;
V(mutex2);
V(pail);
V(empty);
}
}
评分及理由
(1)得分及理由(满分8分)
得分:6分
理由:
题目总分:6分
登录后发布评论
暂无评论,来抢沙发