首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
考研
试修改下面生产者一消费者问题解法中的错误。 producer: begin repeat producer an item in nextp; wait(mutex): wait(full); buf
试修改下面生产者一消费者问题解法中的错误。 producer: begin repeat producer an item in nextp; wait(mutex): wait(full); buf
admin
2019-08-01
82
问题
试修改下面生产者一消费者问题解法中的错误。
producer:
begin
repeat
producer an item in nextp;
wait(mutex):
wait(full);
buffer(in):=nextp:
signal(mutex);
until falsei
end
consumer:
begin
repeat
wait(mutex);
wait(empty);
nextc:=buffer(out):
out:=out+1:
signal(mutex):
consumer item in nextc;
until false;
end
选项
答案
producer: begin repeat producer an item in nextp; wait(mutex): wait(fuU): /*应为wait(empty),而且还应该在wait(utex)的前面*/ buffer(in):=nextp: /*缓冲池数组游标应前移:in:=(in+1)mod n:*/ signal(mutex): /*signal(full):*/ until false; end consumer; begin repeat wait(mutex): wait(empty): /*应为wait(full),而且还应该在wait(mutex)的前面*/ nextc:=buffer(out); out:=out+1; /*考虑循环,应改为:out:=(out+1)mod n:*/ signal(mutex): /*signal(empty)*/ consumer item in nextc: until false; end
解析
转载请注明原文地址:https://kaotiyun.com/show/BkCi777K
本试题收录于:
计算机408题库学硕统考专业分类
0
计算机408
学硕统考专业
相关试题推荐
把中国第一次工人运动的高潮推向顶点的是()。
试述清末新政的内容及其影响。
完整地表述电磁场理论的物理学家是()。
对阿拉伯半岛的统一起了促进作用的宗教是()。
美国主张建立国际联盟的主要目的是()。
【井冈山革命根据地】
重商主义早期追求“少买”,防止贵金属流出,晚期追求“多卖”,实际贸易顺差从少买"到“多卖”变化
高度为7的AVL树最少有()个结点。
某一个计算机系统采用虚拟页式存储管理方式,当前在处理机上执行的某一个进程的页表如下所示,所有的数字均为十进制,每一项的起始编号是0,并且所有的地址均按字节计址,每页的大小为1024字节。(1)计算下列逻辑地址转换为物理地址,并说明为什么?07
随机试题
Apioneeringheadteacheriscallingforallsecondaryschoolstofollowhisleadandstartclassesat11am,allowingteenagers
在pH>10.5的溶液中,EDTA的主要存在形式是()。
Winteristheseasonoftheyear___________thedaysareshortandthenightsarelong.
刷手的顺序
双面阅读型CR其IP的DQE值比普通IP增加了
前视点A的高程为20.503m,读数为1.082m,后视点B的读数为1.102m,则其后视点B的高程为()m。
某有限责任公司章程中的下列规定,不符合《公司法》的是()。
Atthedawnofthe20thcentury,suburbiawasadreaminspiredbyrevulsiontothepovertyandcrowdingofthecities.Inthevi
IknownotmoreFrenchthanIknowLatin.Therefore,Ican’tteacheitherofthem.
Market【C1】______donotcomenaturallytoChineseofficials.Forthepastfouryearstwohugediversion【C2】______havebeenunde
最新回复
(
0
)