文章
156
粉丝
195
获赞
0
访问
28.5k
semaphore mutex_well=1;//互斥使用水井
semaphore mutex_vat=1;//互斥使用水缸
semaphere empty = 10;//水缸还能存储的容量
semaphore full=0;//水缸已有水的桶数
semaphore bucket=3;//水桶的数量
Process YoungMonk:
P(empty) # 等缸有空位
P(buckets) # 等有可用的桶
P(mutex_well) # 等井可用
从井中打水
V(mutex_well)
P(mutex_vat) # 等缸可用(与老和尚互斥)
倒水入缸
V(mutex_vat)
V(buckets) # 还桶
V(full) # 缸中水增加一桶
Process OldMonk:
P(full) # 等缸有水
P(buckets) # 等有可用的桶
P(mutex_vat) # 等缸可用(与小和尚互斥)
从缸中取水
V(mutex_vat)
V(buckets) # 还桶
V(empty) # 缸中空位增加一个
喝水
评分及理由
(1)信号量定义部分(满分2分)
得分:1分
理由:学生定义了5个信号量,基本符合题目要求。但存在以下问题:
- "semaphere empty = 10" 拼写错误,应为"semaphore"(扣0.5分)
- "buckets"...
登录后发布评论
暂无评论,来抢沙发