- 6
- 0
- 约2.53万字
- 约 58页
- 2018-02-18 发布于浙江
- 举报
OS的02进程同步2014-2015-2
管程定义的是公共数据结构; 进程定义的是私有数据结构PCB 管程把共享变量上的同步操作集中起来 临界区却分散在每个进程中; 管程的设置则是解决共享资源的互斥使用问题 设置进程的目的在于实现系统的并发性; 进程通过调用管程中的过程对共享数据结构实行操作 管程为被动工作方式,进程则为主动工作方式; * 同步和互斥并存 * 基于一个条件协作:不空,不满 * 生产者可以通过过程Put往buffer中增加数据; * * 循环体:至少执行一次,条件为true,退出循环。 问题:共享资源buffer的访问通过共享变量counter来协调,对它的访问也未加控制 * 不是原子操作。 * 4个部分,例子 * 有限等待:退出前,必须释放资源。避免饿死 让权等待:CPU “让权等待”:让何权? 同时满足这4个条件,才是合格的同步机制。 * 但通过这类方法的分析,可以更好地理解并发处理的复杂性 * 不响应中断,不会引发调度 In a uniprocessor system, concurrent processes cannot have overlapped execution; they can only be interleaved. Furthermore, a process will continue to run until it invokes an OS service or until it is interrupted. Therefore, to guarantee mutual exclusion, it is sufficient to prevent a process from being interrupted. This capability can be provided in the form of primitives defined by the OS kernel for disabling and enabling interrupts. Because the critical section cannot be interrupted, mutual exclusion is guaranteed. The price of this approach, however, is high. The efficiency of execution could be noticeably degraded because the processor is limited in its ability to interleave processes. Another problem is that this approach will not work in a multiprocessor architecture. When the computer includes more than one processor, it is possible (and typical) for more than one process to be executing at a time. In this case, disabled interrupts do not guarantee mutual exclusion. * * 信号机制才协调多个进程之间的协作机制。受信号灯启发:进程——汽车 资源——车道(路权)。 英文:旗语。通过信号等控制进程的执行、等待。 它与一般整型量不同, S=0 不可用,红灯 wait(S)和signal(S)是两个原子操作,因此,它们在执行时是不可中断的。亦即,当一个进程在修改某信号量时,没有其他进程可同时对该信号量进行修改。此外,在wait操作中,对S值的测试和做S:=S-1操作时都不可中断。 wait(S):不断检测是否为红灯,一旦变可用,进入,关门。 signal: 释放资源 * Busy waiting means that a process is waiting for a condition to be satisfied in a tight loop without relinquishing the processor. Alternatively, a process could wait by relinquishing the processor, and block on a condition and wait to be awakened at some appropriate time in the future. Busy waiting can be avoided but incurs the overhead
您可能关注的文档
最近下载
- GB 50205-2020 钢结构工程施工质量验收标准.docx VIP
- 专业入职offer通知书模板及使用指南.pdf VIP
- 2024年衢州职业技术学院单招职业适应性考试必刷测试卷最新.docx VIP
- 八篇党支部党员在学习贯彻党的创新理论、加强党性锤炼、联系服务群众、发挥先锋模范作用、改作风树新风五个方面202年度个人对照检查.docx VIP
- 水利施工组织设计资料.doc VIP
- 2026中国水溶性肥料市场运营态势与未来发展新动向趋势建议报告.docx
- 2025年化工工程师固定床反应器反应器设计中的商业化专题试卷及解析.pdf VIP
- 2025年互联网营销师区块链营销合作伙伴的选择与生态构建专题试卷及解析.pdf VIP
- 2025年房地产经纪人抵押物灭失、毁损后的处理与登记专题试卷及解析.pdf VIP
- 统编版六年级语文下册课件《文言文二则-两小儿辩日》.pptx VIP
原创力文档

文档评论(0)