四川大学:《操作系统 Operating System》课程教学资源(PPT课件讲稿)Chapter 5 互斥与同步(Mutual Exclusion and Synchronization)5.3 Semaphores

Chapter 5 Mutual Exclusion and Synchronization 5.1 Principles of Concurrency ·5.2 Mutua|EXc| usion .5. 3 Semaphores ·54 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

5.3 Semaphores .5.3 1 What is semaphore? 5.3.2 Two Uses of semaphores 5.3.3 Producer/consumer problem 5.3.4 Implement of Semaphores 5.3.5 Semaphore in UNIX
3 5.3 Semaphores • 5.3.1 What is semaphore? • 5.3.2 Two Uses of Semaphores • 5.3.3 Producer/Consumer Problem • 5.3.4 Implement of Semaphores 5.3.5 Semaphore in UNIX

5.3. 1 What is semaphore?(1/ 10) Mutual exclusion d2> ECg / Sif DrDo=S. if arDe >o √
5.3.1 What is semaphore?(1/10) • Mutual exclusion 4

5.3. 1 What is semaphore?(2/ 10) Synchronization a facility that enforces mutual exclusion and event ordering(必须按规定的先后顺序) Common synchronization mechanism Semaphore, Binary semaphore, Mutex, Condition variable, Monitor, Event flags, Messages Asynchronization??
5.3.1 What is semaphore?(2/10) • Synchronization • A facility that enforces mutual exclusion and event ordering(必须按规定的先后顺序). • Common synchronization mechanism: • Semaphore, Binary semaphore, Mutex, Condition variable, Monitor, Event flags, Messages • Asynchronization?? 5

5.3. 1 What is semaphore? (3/10) ⑨8:12 57,500 e●巴V °四图 52,500 /阕图 6,625 常185000 XP750
5.3.1 What is semaphore?(3/10) 6

5.3.1 What is semaphore? (4/10) Semaphore is a ty pe of generalized lock Defined by dijkstra in the last 60s Main synchronization primitives used in UNIX
5.3.1 What is semaphore?(4/10) • Semaphore is a type of generalized lock • Defined by Dijkstra in the last 60s • Main synchronization primitives used in UNIX 7

5.3.1 What is semaphore? (5/10) Semaphores have a non-negative integer value, and support two operations PO: an atomic operation that waits for semaphore to become positive, then decrement it by 1 VO: an atomic operation that increments semaphore by 1 and wakes up a waiting thread at Po, if any · Features: Only operations are PO and vo Cannot read or write semaphore values Except at the initialization times Operations are atomic A sleeping thread at po cannot miss a wakeup from Vo
5.3.1 What is semaphore?(5/10) • Semaphores have a non-negative integer value, and support two operations • P(): an atomic operation that waits for semaphore to become positive, then decrement it by 1 • V(): an atomic operation that increments semaphore by 1 and wakes up a waiting thread at P(), if any. • Features: • Only operations are P() and V() • Cannot read or write semaphore values • Except at the initialization times • Operations are atomic • A sleeping thread at P() cannot miss a wakeup from V() 8

5.3.1 What is semaphore? (6/10 Semaphore Primitives(原语,原子操作) struct semaphore t int count: crueueType queue void semWait(semaphore s) s. count if(s count 0) place this process in s queue b⊥ ck this process void semsigmal ( semaphore s) s. count++i if (s count <= 0) remove a process p from squeue; place process p on ready list Figure 5.3 A Definition of Semaphore Primitives
5.3.1 What is semaphore?(6/10) • Semaphore Primitives(原语,原子操作) 9 P V

5.3.1 What is semaphore? (7/10 Binary Semaphore(二元信号量) a binary semaphore is initialized to 1 PO waits until the value is 1 · Then set it to0 VO sets the value to 1 Wakes up a thread waiting at PO, if any
5.3.1 What is semaphore?(7/10) • Binary Semaphore(二元信号量) • A binary semaphore is initialized to 1 • P() waits until the value is 1 • Then set it to 0 • V() sets the value to 1 • Wakes up a thread waiting at P(), if any 10

5.3.1 What is semaphore? (8/10 Binary semaphore primitives struct binary semaphore enum (zero, one) value; crueueType queue void semwaitB(binary semaphore s) if(s value = 1) s, value o else place this process in s queue block this process; void semsignalB (semaphore s) if(s queue. is empty() s. value 1 else remove a process p from s queue place process p on ready listi Figure 5.4 A Definition of Binary Semaphore Primitives
5.3.1 What is semaphore?(8/10) • Binary Semaphore Primitives 11 P V
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《编译原理》课程教学资源(PPT课件讲稿)第五章 语法制导的翻译 5.1 语法制导的定义 5.2 S属性定义的自下而上计算.ppt
- 《数字图像处理》课程教学资源(PPT课件讲稿)第7章 图像分割.ppt
- 《人工智能》课程电子教案(PPT课件讲稿)第9章 机器学习与知识发现.ppt
- 赣南师范大学:《计算机网络原理》课程教学资源(PPT课件讲稿)第七章 网络层.ppt
- 四川大学:《计算机操作系统 Operating System Principles》课程教学资源(PPT课件讲稿)第1章 导论(主讲:段磊).ppt
- 搜索引擎技术(PPT讲稿)Web Spam.ppt
- 电子科技大学:《密码理论》课程教学资源(PPT课件讲稿)第2章 流密码.ppt
- 《编译原理》课程教学资源(PPT课件讲稿)语法制导的翻译(Syntax-Directed Translation).pptx
- 《Photoshop CS教程》教学资源(PPT课件)第7章 编辑文字.ppt
- 西南交通大学:《网络性能评估与测试 Network Performance Evaluation and Testing》(PPT课件讲稿)第2讲 网络测试技术基础(主讲:张新有).ppt
- 《数据结构》课程教学资源(PPT课件讲稿)第五章 多维数组与广义表.ppt
- 上海交通大学:超立方体 Hypercube(PPT讲稿)Low-Diameter Architectures.ppt
- 东北大学:《计算机图形学》课程教学资源(PPT课件讲稿,主讲:闻时光).ppt
- 《数据结构》课程教学资源(PPT课件讲稿)第四章 串.ppt
- 《现代操作系统 Modern Operating Systems》课程教学资源(PPT课件讲稿,Third Edition)Chapter 3 内存管理 Memory Management.ppt
- 《网络编程实用教程》课程教学资源(PPT课件讲稿)第2章 套接字网络编程基础.ppt
- 《软件工程》课程教学资源(PPT课件)Lecture 6 设计概念和原则 Design Concepts and Principles.ppt
- 西安交通大学:《微机原理与接口技术》课程教学资源(PPT课件讲稿)第6章 数字量输入输出接口(主讲:桂小林).ppt
- 香港中文大学:《Probability and Statistics for Engineers》课程教学资源(PPT课件讲稿)Chapter 09 Classical Staistical Inference.pptx
- 上海交通大学:《挖掘海量数据集 Mining Massive Datasets》课程教学资源(PPT讲稿)Lecture 07 链接分析 Link Analysis.ppt
- 淮阴工学院:《数据库原理》课程教学资源(PPT课件讲稿)第2章 数据库系统结构.ppt
- 苏州大学:文档评分与向量空间模型(PPT讲稿).ppt
- 清华大学:Computational Models for Social Network Analysis(PPT讲稿)mining big social networks(Part III:Group and Structure).pptx
- 中国科学技术大学:《网络信息安全 NETWORK SECURITY》课程教学资源(PPT课件讲稿)第一章 计算机网络安全概述2/2(主讲:肖明军).ppt
- 《计算机硬件基础》课程教学资源(PPT课件讲稿)第六章 汇编语言及其程序设计.ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第四章 指令系统及汇编语言程序设计(4.9-4.11).ppt
- 《C语言程序设计》课程教学资源(PPT课件讲稿)第三章 控制语句.ppt
- 《机器学习》课程教学资源(PPT课件讲稿)第十三章 半监督学习.pptx
- 《数字图像处理》课程教学资源(PPT课件)第三章 灰度直方图.ppt
- 《电子技术》课程教学资源(PPT讲稿资料)玩转Arduino合集.ppt
- 《计算机网络》课程教学资源(PPT课件讲稿)第7章 广域网.ppt
- 电子科技大学:《信息安全概论》课程教学资源(PPT课件讲稿)第一章 概述(秦志光).ppt
- 西安交通大学:《微型计算机硬件技术》课程教学资源(PPT课件讲稿)第三章 总线线驱动与接口(主讲:桂小林).ppt
- 基于分布式哈希表的对等系统关键技术研究(论文PPT).ppt
- 山东大学:《人机交互技术》课程教学资源(PPT课件讲稿)第4章 人机交互技术.ppt
- 《C程序设计》课程电子教案(PPT课件)第四章 数组和结构.ppt
- 华东师范大学:《程序设计》课程教学资源(PPT课件讲稿)第九讲 类与对象(面向对象基础).pptx
- 《计算机视觉》课程教学资源(PPT课件讲稿)第十二章 目标识别 Object Recognition.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)引言、背景概述.ppt
- 《数据结构》课程教学资源(PPT课件讲稿)第3章 栈和队列.ppt