- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
第五讲进程同步和通信(partII)9
Readers-Writers problem (cont’d) 写者对共享数据具有独占性 读者-写者问题的变形: The first R/W problem Reader has the higher priority Writer may starve The second R/W problem Writer has the higher priority Reader may starve R/W problem: a solution Shared variable int readcount = 0; Shared semaphore semaphore Wmutex=1; semaphore Rmutex = 1; Writer do{ P(Wmutex); /* perform write operation */ V(Wmute); }while(1); Reader do{ P(Rmutex); if (readcount==0) P(Wmutex); readcount++; V(Rmutex); /* perform read operation */ P(Rmutex); readcount--; if (readcount==0) V(Wmutex); V(Rmutex); }while(1); 利用信号量集解决读者-写者问题 假定最多只允许RN个读者 使用信号量L控制读者的数量 var RN integer; L, mx:semaphore:=RN,1; reader: begin repeat Swait(L,1,1); Swait(mx,1,0); … read … Ssignal(L,1); until false; end writer: beginrepeat Swait(mx,1,1; L,RN,0); …write… Ssignal(mx,1)end Dining-Philosophers Problem哲学家就餐问题 5 philosophers Thinking or eating Only 5 chopsticks Left right One at a time At most 2 philosophers can eat at a time semaphore chopstick[5] ={1,1,1,1,1}; Dining-philosophers problem (cont.) A possible solution Philosopher i Possible deadlock When 5 philosophers each grabs the left chopstick, … Solutions: Philosophers =4 Only if both chopsticks are available, … Odd, first left then right; even, first right then left do{P(chopstick[i]); // leftP(chopstick[(i+1)%5]; // right /* eating */ V(chopstick[i]; V(chopstick[(i+1)%5]; /* thinking */ }while(1); 利用AND信号量解决哲学家就餐问题 var chopstick array of semaphore:=(1,1,1,1,1)process i repeat think; Swait(chopstick[(i+1)mod5], chopstick[i]); eat; Ssignal(chopstick[(i+1)mod5], chopstick[i]); until false; Timing errors Only happen when some particular execution sequences take place For example: counter++; counter--; Difficult to detect Do
您可能关注的文档
最近下载
- SJG 05-2020 基坑支护技术标准.docx VIP
- 综合实践劳动课教案.docx VIP
- 2023年高校教师资格证教育心理学.doc VIP
- 海书专升本刷题测试卷15.docx VIP
- 贵司专升本磨刀进阶营大学英语第一次模拟测试.docx VIP
- 统编版语文二年级上册第四单元、第五单元复习课教案(各一套).doc VIP
- 浅谈宽带电力载波与窄带电力载波在电力抄表中的利弊关系(行业资料).doc VIP
- 护理人员分层培训现状调查.docx VIP
- 2025至2030中国IPv6行业市场发展分析及行业前景预测报告.docx VIP
- 中国临床肿瘤学会(csco)胰腺癌诊疗指南2025.docx VIP
有哪些信誉好的足球投注网站
文档评论(0)