- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* Processes Accessing Shared Data Protected by a Semaphore * Producer/Consumer Problem One or more producers are generating data and placing these in a buffer A single consumer is taking items out of the buffer one at time Only one producer or consumer may access the buffer at any one time …. Producer Consumer Buffer Pool * Producer/Consumer Problem #define N 100 semaphore mutex = 1; semaphore empty = N; semaphore full = 0; void producer(void) { int item; while(true){ produce_item(Item); semWait(empty); semWait(mutex); enter_item(item); semSignal(mutex); semSignal(full); } } void consumer(void) { int item; while(true){ semWait(full); semWait(mutex); remove_item(item); semSignal(mutex); semSignal(empty) consume_item(item); } } * Producer/Consumer Problem #define N 100 semaphore mutex = 1; semaphore empty = N; semaphore full = 0; void producer(void) { int item; while(true){ produce_item(Item); semWait(mutex); semWait(empty); enter_item(item); semSignal(mutex); semSignal(full); } } void consumer(void) { int item; while(true){ semWait(full); semWait(mutex); remove_item(item); semSignal(mutex); semSignal(empty) consume_item(item); } } * Monitors(管程) Monitor is a software module consisting of one or more procedures, an initialization sequence, and local data Chief characteristics Local data variables are accessible only by the monitor’s procedures and not by any external procedure Process enters monitor by invoking one of its procedures Only one process may be executing in the monitor at a time * Condition Variables Condition variable are a special data type in monitors, which are operated on by two operations: cwait(c): suspend execution of the calling process on condition c. The monitor is now ava
您可能关注的文档
最近下载
- 医用氧生产工艺规程.doc VIP
- 200吨汽车吊书说明书.pdf VIP
- 0.中国中铁建筑施工典型异常工况安全处置工作指引宣贯材料.pptx VIP
- 2025年河北唐山市路南区专项选聘教师168人笔试备考题库及答案解析.docx VIP
- HanbellRC系列半封闭螺杆压缩机产品样本-RC系列.PDF VIP
- 15J401 钢梯标准图集.pptx VIP
- 山东科学技术版劳动实践指导手册六年级第2课整理与收纳居室整理与清洁学会消毒 教案.docx VIP
- 技嘉主板H610M S2 DDR4 (rev.1.1)用户手册简体中文(版本 1001).pdf
- 2025年河北唐山市路南区选调教师30人笔试备考试题及答案解析.docx
- 2024单簧管协奏曲《帕米尔之音》演奏技巧分析5300字.docx VIP
文档评论(0)