- 1、本文档共61页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
ch07-Process Synchronization
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris 2 Windows 2000 Background Concurrent access to shared data may result in data inconsistency. Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. Shared-memory solution to bounded-butter problem (Chapter 4) allows at most n – 1 items in buffer at the same time. A solution, where all N buffers are used is not simple. Suppose that we modify the producer-consumer code by adding a variable counter, initialized to 0 and incremented each time a new item is added to the buffer Bounded-Buffer Shared data #define BUFFER_SIZE 10 typedef struct { . . . } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; int counter = 0; Bounded-Buffer Producer process item nextProduced; while (1) { while (counter == BUFFER_SIZE) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; counter++; } Bounded-Buffer Consumer process item nextConsumed; while (1) { while (counter == 0) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; } Bounded Buffer The statementscounter++;counter--;must be performed atomically. Atomic operation means an operation that completes in its entirety without interruption. Bounded Buffer The statement “count++” may be implemented in machine language as:register1 = counter register1 = register1 + 1counter = register1 The statement “count—” may be implemented as:register2 = counterregister2 = register2 – 1counter = register2 Bounded Buffer If both the producer and consumer attempt to update the buffer concurrently, the assembly language statements may get interleaved. Interleaving depends upon how the producer and consumer processes are scheduled. Bounded Buffer Assume counter is initially 5.
您可能关注的文档
- 高三英语课件M10 Unit.3 workbook.ppt
- 高中短文改错解题技巧.ppt
- 高三英语课件:Unit9 Health Care Reading.ppt
- 高中英语M7U4Language.ppt
- 高三英语课件:fashion in China and Western Country.ppt
- 高三复习语法专题——冠词的用法.ppt
- 高中英语常考动词短语归纳文档.doc
- 高中英语必修4第四单元综合测评.doc
- 高中英语必修一第二单元Reading and Speaking.ppt
- 高中英语新课标(人教版)优秀课件 选修六 1.3《Unit1 Art》(可编辑PPT课件)unit1.ppt
- 2024-2025学年江苏省宿迁市沭阳县高一(下)期末数学试卷(含解析).docx
- 2024-2025学年江苏省宿迁市沭阳县高一(下)期末数学试卷(含答案).docx
- 2024-2025学年江苏省镇江市句容市高一(下)期中数学试卷(含答案).docx
- 2024-2025学年吉林省长春市慧泽高中高一(下)期末数学试卷(含答案).docx
- 2024-2025学年吉林省长春市希望中学高一(下)期末数学试卷(含解析).docx
- 2024-2025学年吉林省长春市希望中学高一(下)期末数学试卷(含答案).docx
- 2024-2025学年吉林省长春市慧泽高中高一(下)期末数学试卷(含解析).docx
- 2024-2025学年吉林省四平市高一(下)期中数学试卷(含答案).docx
- 2024-2025学年吉林省白城市洮南一中高二(下)期末数学试卷(含解析).docx
- 2024-2025学年吉林省白城市洮南一中高二(下)期末数学试卷(含答案).docx
最近下载
- 沿着塞纳河到翡冷翠.pdf VIP
- 2025甘肃定西市招聘专业化管理村党组织书记103人考试备考试题及答案解析.docx VIP
- 一种小鼠结直肠原位癌模型的构建方法.pdf VIP
- 百度地图-北京市购物中心报告-71页.pdf VIP
- 克莱斯勒-Grand Voyager-产品使用说明书-Grand Voyager(3.6L)-Grand Voyager(3.6L)-2013款大捷龙用户手册(产品使用说明书).pdf
- 居住绿地设计标准.pdf VIP
- 新媒体短视频代运营.pptx VIP
- 人教版(2025)八年级英语上册 Unit 1 Happy Holiday单元检测卷(含答案及听力原文,无听力音频).doc VIP
- 2025人教版英语四年级上册Unit 4 Helping in the community单元测试试卷.docx VIP
- 企业短视频代运营.pptx VIP
文档评论(0)