- 1、本文档共159页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Chapter 7: Process Synchronization进程同步 7.1 Background 背景 7.2 The Critical-Section Problem 临界区问题 7.3 Synchronization Hardware 同步的硬件实现 7.4 Semaphores 信号量 7.5 Classical Problems of Synchronization 经典同步问题 7.6 Critical Regions 临界区 7.7 Monitors 管程 7.8 OS Synchronization 操作系统的同步机制 7.9 Atomic Transactions 原子事务处理 7.1 Background背景 Concurrent access to shared data may result in data inconsistency. 对共享数据的并发访问可能导致数据的不一致性 Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. 要保持数据的一致性,就需要一种保证并发进程的正确执行顺序的机制 Background (Cont.) 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. 第4章中解决有限缓冲区问题的共享内存方法…N项的缓冲器最多只能使用n-1项 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 假定我们通过增加一个计数器变量修改生产者-消费者代码,初始值为 0,在缓冲区增加一个项目(数据)计数器加1 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 (Cont.-1) Producer process item nextProduced; while (1) { while (counter == BUFFER_SIZE) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; counter++; } Bounded-Buffer (Cont.-2) Consumer process item nextConsumed; while (1) { while (counter == 0) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; } Bounded Buffer (Cont.-3) The statementscounter++;counter--;must be performed atomically.
您可能关注的文档
- $8.2 分组试验设计.ppt
- -远程教育与Internet.ppt
- 1 美国哈佛大学2 美国斯坦福大学 3 美国耶鲁大学 4 美国加州.ppt
- 1 钢结构的材料与计算方法.ppt
- 1 饮用水水质评价 2 工业用水水质评价 3 农田灌溉用水水质评.ppt
- 1. 经管类本科实践教学内容体系2. 经管类本科实验教学及其意.ppt
- 1.低层大气的组成成分 2.各组成成分的作用?3.人类活动对大.ppt
- 1.化合价有正价和负价。.ppt
- 1.回潮率与含水率回潮率W:纺织材料中所含水分重量对纺织.ppt
- 1.学校有20个足球,篮球比足球多 1-4 ,篮球有多少个?2.学.ppt
- Charles Severance-Sakai and Portals.ppt
- Charles.Harrington-Wireless Telecommunications Bureau Ag.ppt
- Chemistry on Nonmetals Nonmetallic Materials.ppt
- Controlling the pollution of boiler smoke and dust锅炉烟尘污染.ppt
- C语言程序设计 (第二版)主编 王曙燕.ppt
- DNA--不朽的双螺旋.ppt
- Doripenem - A New Broad-Spectrum Carbapenem Antibiotic.ppt
- Down Up of Credit Card Industry in Korea韩国信用卡业的启.ppt
- E N E R G Y.ppt
- Ectopic pregnancy.ppt
文档评论(0)