四川大学:《操作系统 Operating System》课程教学资源(PPT课件讲稿)Chapter 5 互斥与同步(Mutual Exclusion and Synchronization)5.4 Monitors 5.5 Message Passing 5.6 Readers/Writers Problem

Chapter 5 Mutual Exclusion and Synchronization 5.1 Principles of Concurrency ·5.2 Mutua|EXc| usion 5.3 Semaphores 5. 4 Monitors 5.5 Message Passing 5.6 Readers /writers problem .5. Summary
2 Chapter 5 Mutual Exclusion and Synchronization • 5.1 Principles of Concurrency • 5.2 Mutual Exclusion • 5.3 Semaphores • 5.4 Monitors • 5.5 Message Passing • 5.6 Readers/Writers Problem • 5.7 Summary

Last Class: Semaphores A semaphore S supports two atomic operations SPO: get a semaphore, wait if busy semaphore s is available SVO: release the semaphore, wake up a process if one is waiting for s Types of semaphore Binary or Mutex Semaphore: grants mutual exclusive access to a resource Counting Semaphore: useful for granting mutually exclusive access for a set of resources Semaphores are difficult to use: orders are important
Last Class: Semaphores • A semaphore S supports two atomic operations • S→P(): get a semaphore, wait if busy semaphore S is available. • S→V(): release the semaphore, wake up a process if one is waiting for S. • Types of semaphore • Binary or Mutex Semaphore: grants mutual exclusive access to a resource • Counting Semaphore: useful for granting mutually exclusive access for a set of resources • Semaphores are difficult to use: orders are important 3

Solution higher level primitive oS codes and concurrent applications High-Level Mutex Semaphores Monitors Send/Recv Atomic API LoW-Level Load/store Interrupt Test& Set Other atomic Atomic Ops disable/enable instructions interrupts CPU (1/0, timer) Multiprocessors scheduling
Solution:higher level primitive 4

5.4 Monitors .5 4.1 Concept of monitors 5.4.2 Producer-Consumer with monitors
5.4 Monitors • 5.4.1 Concept of Monitors • 5.4.2 Producer-Consumer with Monitors 5

5.4.1 Concept of Monitors(1/10) Monitor(管程) A high-level abstraction that provides a convenient and effective mechanism for process synchronization Only one process/thread may be executing in the monitor at a time
5.4.1 Concept of Monitors(1/10) • Monitor(管程) • A high-level abstraction that provides a convenient and effective mechanism for process synchronization. • Only one process/thread may be executing in the monitor at a time. 6

5.4.1 Concept of Monitors(2/10) .a Formal definition A monitor defines a lock and zero or more condition variables for managing concurrent access to shared data The monitor uses the lock to insure that only a single thread is active in the monitor at any instance The lock also provides mutual exclusion for shared data Condition variables enable threads to go to sleep inside of critical sections, by releasing their lock at the same time it puts the thread to sleep
5.4.1 Concept of Monitors(2/10) • A Formal Definition • A Monitor defines a lock and zero or more condition variables for managing concurrent access to shared data. • The monitor uses the lock to insure that only a single thread is active in the monitor at any instance. • The lock also provides mutual exclusion for shared data. • Condition variables enable threads to go to sleep inside of critical sections, by releasing their lock at the same time it puts the thread to sleep. 7

5.4.1 Concept of Monitors(3/10) · Monitor operations: Encapsulates the shared data you want to protect Acquires the mutex at the start Operates on the shared data Temporarily releases the mutex if it can't complete Reacquires the mutex when it can continue Releases the mutex at the end
5.4.1 Concept of Monitors(3/10) • Monitor operations: • Encapsulates the shared data you want to protect. • Acquires the mutex at the start. • Operates on the shared data. • Temporarily releases the mutex if it can't complete. • Reacquires the mutex when it can continue. • Releases the mutex at the end. 8

5.4.1 Concept of Monitors(4/10) Structure of a monitor queue entering processes monitor waiting area Entrance Lock MONITOR condition cl local data waitre I condition variables Procedure l Condition Variables condition er ewalt(cn) Procedure k 工兽 urgent queue initialization code Lxi量 re s.1s Structure of a Monitor
5.4.1 Concept of Monitors(4/10) • Structure of a Monitor 9 Lock Condition Variables

5.4.1 Concept of Monitors (5/10) Procedures are mutual exclusive Shared data Queue of waiting processes trying to enter the monitor procedures
5.4.1 Concept of Monitors(5/10) • Procedures are mutual exclusive 10

5.4.1 Concept of Monitors(6/10) It is simple to turn a java class into a monitor Make all the data private Make all methods synchronized or at least the non private ones) class Queuet private…;∥/ queue data public void synchronized Add( object item t put item on queue public object synchronized removed i if queue not empty i remove item return item
5.4.1 Concept of Monitors(6/10) • It is simple to turn a Java class into a monitor: • Make all the data private • Make all methods synchronized (or at least the non - private ones) 11 class Queue{ private ...; // queue data public void synchronized Add( Object item ) { put item on queue; } public Object synchronized Remove() { if queue not empty { remove item; return item; } }
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《程序设计》课程教学资源(PPT课件讲稿)第6章 过程封装——函数.ppt
- 《3ds Max》教学资源(PPT课件)第4章 基本三维模型的创建.ppt
- 南京大学:复杂系统学习(PPT课件讲稿)佩特里网 Petri Nets.pptx
- 香港科技大学:《软件开发》教学资源(PPT课件讲稿)Functions.ppt
- 《计算机文化基础》课程教学资源(PPT课件讲稿)第二章 Windows XP操作系统.ppt
- 电子科技大学:《计算机操作系统》课程教学资源(PPT课件讲稿)第五章 设备管理.ppt
- 山东大学:语音识别技术(PPT课件讲稿)自动语音识别 Automatic Speech Recognition.pptx
- 数据集成 Data Integration(PPT讲稿)成就与展望 Achievements and Perspectives.ppt
- 北京师范大学:拓扑序及其量子相变(PPT课件讲稿)Topological Order and its Quantum Phase Transition.ppt
- 计算机系教学资源(PPT课件讲稿)信息安全与保密技术.ppt
- 汤姆森 Thomson:利用Web of Knowledge对课题进行检索、分析、跟踪、管理.ppt
- 西安电子科技大学:《微机原理与接口技术》课程教学资源(PPT课件讲稿)第九章 定时/计数器8253.pptx
- 同济大学:聚类分析(PPT课件讲稿)Cluster Analysis.pptx
- 《数字图像处理学》课程教学资源(PPT课件讲稿)第2章 图像、图像系统与视觉系统.pptx
- 四川大学:《软件测试与维护基础教程》课程教学资源(PPT课件讲稿)软件测试工具 Software Testing Tool.ppt
- B-树、散列技术、散列表的概念、散列函数的构造方法、处理冲突的方法、散列表上的运算.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)对象序列化和持久化 Object Serialization and Persistence.ppt
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第十章 下一代因特网.ppt
- 《网络编程实用教程(第三版)Network Application Programming》课程教学资源(PPT课件讲稿)第1章 概述.ppt
- 武昌理工学院(武汉科技大学中南分校):Windows 2000/XP网络组建与系统管理(PPT课件讲稿,主讲:李燕).ppt
- 清华大学:An Efficient Trie-based Method for Approximate Entity Extraction with Edit-Distance Constraints.pptx
- 东南大学:《数据结构》课程教学资源(PPT课件讲稿)第三章 栈与队列.ppt
- 《计算机网络与因特网 Computer Networks and Internets》课程教学资源(PPT课件讲稿)Part II 物理层(信号、媒介、数据传输).ppt
- 合肥工业大学:《网络安全概论》课程教学资源(PPT课件讲稿)第2讲 密码学简介(主讲:苏兆品).ppt
- 长春大学:《计算机应用基础》课程教学资源(PPT课件讲稿)第一章 计算机基础知识(崔天明).ppt
- 《Java网站开发》教学资源(PPT讲稿)第9章 过滤器和监听器技术.ppt
- 北京师范大学现代远程教育:《计算机应用基础》课程教学资源(PPT课件讲稿)第2章 计算机网络应用.ppsx
- 清华大学:A Feature Weighting Method for Robust Speech Recognition(Speech Activities in CST).ppt
- 西安电子科技大学:《神经网络与模糊系统》课程教学资源(PPT课件讲稿)Chapter 6 结构和平衡 Architecture and Equilibria.ppt
- 北京大学:人工神经网络(PPT课件讲稿)Artificial Neural Networks,ANN.ppt
- 《计算机组成原理》课程教学资源(PPT课件讲稿)第4章 处理器(CPU).ppt
- 吉林大学:《C语言》课程教学资源(PPT课件讲稿)第6章 利用数组处理批量数据.ppt
- 《Vb程序设计教程》课程教学资源(PPT课件讲稿)第三章 VB语言基础.pps
- 安徽理工大学:《汇编语言》课程教学资源(PPT课件讲稿)第七章 高级汇编语言技术(主讲:李敬兆).ppt
- 《软件质量与测试》课程教学资源(PPT大纲课件,目录版).pptx
- 香港理工大学:Discovering Classification Rules.ppt
- 北京科技大学:物联网知识体系和学科建设(PPT讲稿,王志良).ppt
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)傅里叶分析与卷积 Fourier Analysis and Convolution.pptx
- 沈阳理工大学:《单片机C语言应用程序设计》课程PPT教学课件(单片机C语言编程)04 C51编程设计(廉哲).pptx
- 《软件工程 Software Engineering》教学资源:课程教学大纲.pdf