东南大学:《操作系统概念 Operating System Concepts》课程教学资源(PPT课件讲稿)06 Process synchronization

●●● ●●●● 6. Process synchronization 9989 ●●●0 Objectives ●●●● To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To present both software and hardware solutions of the critical-section problem o introduce the concept of an atomic transaction and describe mechanisms to ensure atomicity
2 6. Process synchronization ⚫ Objectives ⚫ To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data ⚫ To present both software and hardware solutions of the critical-section problem ⚫ To introduce the concept of an atomic transaction and describe mechanisms to ensure atomicity

●●● ●●●● 6. Process synchronization 9988 ●●●● e 6.1 Background ●●●● o 6.2 The Critical-Section Problem °6.3 Peterson’sSo|uton 6.4 Synchronization Hardware 6.5 Semaphores o 6.6 Classic Problems of synchronization ●67 Monitors e 6.8 Synchronization Examples o 6.9 Atomic transactions
3 6. Process synchronization ⚫ 6.1 Background ⚫ 6.2 The Critical-Section Problem ⚫ 6.3 Peterson’s Solution ⚫ 6.4 Synchronization Hardware ⚫ 6.5 Semaphores ⚫ 6.6 Classic Problems of Synchronization ⚫ 6.7 Monitors ⚫ 6.8 Synchronization Examples ⚫ 6.9 Atomic Transactions

●●● ●●●● 6.1 Background ●●●●● ●●●● ●●0●● ●●●0 o Concurrent access to shared data may result in data inconsistency o A example: bounded buffer problem with shared data o Producer while(true)( produce an item in nextProduced * while(count== BUFFER SIZE); /do nothing buffer [in]= nextProduced; in=(in+1)% BUFFER SIZE count++
4 6.1 Background ⚫ Concurrent access to shared data may result in data inconsistency ⚫ A example: bounded buffer problem with shared data ⚫ Producer while (true) { /* produce an item in nextProduced */ while (count == BUFFER_SIZE); // do nothing buffer [in] = nextProduced; in = (in + 1) % BUFFER_SIZE; count++; }

●●● ●●●● 6.1 Background ●●●●● ●●●● ●●0●● ●●●● Consumer ●●●● while(true)t while(count==0); //do nothing nextConsumed= buffer[out] out=out+ 1)% BUFFER SIZE count--, /* consume the item in nextconsumed*/ o The statements /* count=5*/ count++e l/Producer count-- ∥/ Consumer
5 6.1 Background ⚫ Consumer while (true) { while (count == 0); // do nothing nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; count--; /* consume the item in nextConsumed*/ } ⚫ The statements /* count=5 */ count++; //Producer count--; // Consumer

●●● ●●●● 6.1 Background ●●●●● ●●●● ●●0●● ●●●● o count++ could be implemented as ●●●● register1 count register1 register1+ 1 count= register1 o count--could be implemented as register2= count register2 register2 -1 count= register2 Remember that the contents of the register will be saved and restored by the interrupt
6 6.1 Background ⚫ count++ could be implemented as register1 = count register1 = register1 + 1 count = register1 ⚫ count-- could be implemented as register2 = count register2 = register2 - 1 count = register2 Remember that the contents of the register will be saved and restored by the interrupt

●●● ●●●● 6.1 Background ●●●●● ●●●● ●●0●● ●●●0 ● f both the producer and consumer attempt to。 update the buffer concurrently, the assembly language statements may get interleaved One such interleaving is TO: producer execute register1=count [register1= 5] T1: producer execute register1= register1+1 register1= 6] T2: consumer execute register2=count Register= 5) T3: consumer execute register2= register2 -1 register2=41 T4: consumer execute count= register2 Icount=4] T5: producer execute count= registert Icount=61 The value of count may be either 4 or 6, where the correct result should be 5
7 6.1 Background ⚫ If both the producer and consumer attempt to update the buffer concurrently, the assembly language statements may get interleaved ⚫ One such interleaving is T0: producer execute register1 = count {register1 = 5} T1: producer execute register1 = register1 + 1 {register1 = 6} T2: consumer execute register2 = count {register2 = 5} T3: consumer execute register2 = register2 - 1 {register2 = 4} T4: consumer execute count = register2 {count = 4} T5: producer execute count = register1 {count = 6 } ⚫ The value of count may be either 4 or 6, where the correct result should be 5

●●● ●●●● 6.1 Background ●●●●● ●●●● ●●0●● ●●●0 Race condition(竟争状态读写的交错情形)°° The situation where several processes access and manipulate shared data concurrent o The final value of the shared data depends upon which process finishes last Solution---Synchronized Concurrent process must be synchronized To prevent race conditions and maintain data consistency requires mechanisms to ensure the orderly execution of cooperating processes ( serialization在临界区串行化) How
8 6.1 Background ⚫ Race condition (竞争状态---读写的交错情形) ⚫ The situation where several processes access and manipulate shared data concurrently. ⚫ The final value of the shared data depends upon which process finishes last. ⚫ Solution---Synchronized ⚫ Concurrent process must be synchronized ⚫ To prevent race conditions and maintain data consistency requires mechanisms to ensure the orderly execution of cooperating processes (serialization 在临界区串行化) ⚫ How ?

●●● ●●●● 6. Process synchronization 9988 ●●●● e 6.1 Background ●●●● o 6.2 The Critical-Section Problem °6.3 Peterson’sSo|uton 6.4 Synchronization Hardware 6.5 Semaphores o 6.6 Classic Problems of synchronization ●67 Monitors e 6.8 Synchronization Examples o 6.9 Atomic transactions
9 6. Process synchronization ⚫ 6.1 Background ⚫ 6.2 The Critical-Section Problem ⚫ 6.3 Peterson’s Solution ⚫ 6.4 Synchronization Hardware ⚫ 6.5 Semaphores ⚫ 6.6 Classic Problems of Synchronization ⚫ 6.7 Monitors ⚫ 6.8 Synchronization Examples ⚫ 6.9 Atomic Transactions

●●● ●●●● 6.2 The Critical-Section Problem :: ●●●● ° Critica| section ●●●● The n processes compete to use some shared data(临界资源) o Changing common variables o updating a table writing a file o Each process has a code segment, called critical section, in which the shared data is accessed
10 6.2 The Critical-Section Problem ⚫ Critical section ⚫ The n processes compete to use some shared data (临界资源) ⚫ Changing common variables ⚫ updating a table ⚫ writing a file ⚫ Each process has a code segment, called critical section, in which the shared data is accessed

●●● ●●●● 6.2 The Critical-Section Problem: ●●●0 e The critical section problem ●●●● o Be how to design a protocol that One process is executing in its critical section, no other process is to be allowed to execute in its critical section of accessing the same shared data No two processes are executing in their critical section at the same time
11 6.2 The Critical-Section Problem ⚫ The critical section problem ⚫ Be how to design a protocol that ⚫ One process is executing in its critical section, no other process is to be allowed to execute in its critical section of accessing the same shared data ⚫ No two processes are executing in their critical section at the same time
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 河南中医药大学:《数据库原理》课程教学资源(PPT课件讲稿)第一章 绪论.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)第4章 存储层次结构设计.ppt
- 西安交通大学:《网络与信息安全》课程PPT教学课件(网络入侵与防范)第一章 网络安全概述(主讲:沈超、刘烃).ppt
- 《管理信息系统》课程教学资源(PPT课件讲稿)第16章 新型数据库技术及发展.ppt
- 北京大学:《软件需求工程》课程教学资源(PPT课件讲稿)第三章 软件需求获取(主讲:周立新).ppt
- 电子工业出版社:《计算机网络》课程教学资源(第六版,PPT课件讲稿)第三章 数据链路层.pptx
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第四章 指令系统及汇编语言程序设计(4.1-4.6).ppt
- 西北农林科技大学:高性能计算之并行编程技术(讲座PPT,报告人:周兆永).ppt
- 《计算机操作系统》课程教学资源(PPT课件讲稿)第8章 计算机系统的测试.ppt
- 数据包检测技术(PPT讲稿)High-Performance Pattern Matching for Intrusion Detection.ppt
- 中国科学技术大学:《信号与图像处理基础 Signal and Image Processing》课程教学资源(PPT课件讲稿)图像成像机理与模型.pptx
- 中国科学技术大学:《算法基础》课程教学资源(PPT课件讲稿)第八讲 串匹配算法(主讲:顾乃杰).ppt
- 《计算机视觉》课程教学资源(PPT课件)第八章 基于运动视觉的稠密估计——光流法(Optical Flow).ppt
- 东南大学:《操作系统概念 Operating System Concepts》课程教学资源(PPT课件讲稿)04 线程 Threads.ppt
- 《数字图像处理学》课程教学资源(PPT课件讲稿)第9章 数学形态学及其应用.ppt
- 南京航空航天大学:《数据结构》课程教学资源(PPT课件讲稿)第一章 绪论.ppt
- 《大学计算机》实践教程(PPT讲稿)面向计算思维能力培养(Raptor程序设计).pptx
- 机械工业出版社:国家“十一五”规划教材《数据库原理与应用教程》教学资源(PPT课件,第3版)第8章 数据库设计.ppt
- 安徽理工大学:《汇编语言》课程教学资源(PPT课件讲稿)第三章 80x86指令系统和寻址方式.ppt
- 广西医科大学:《计算机网络 Computer Networking》课程教学资源(PPT课件讲稿)CHAPTER 9 COMMUNICATIONS CIRCUITS.pptx
- 上海交通大学:《Multicore Architecture and Parallel Computing》课程教学资源(PPT课件讲稿)Lecture 8 CUDA, cont’d.ppt
- 赣南师范大学:《计算机网络原理》课程教学资源(PPT课件讲稿)第四章 数据链路层.ppt
- 南京大学:移动Agent系统支撑(PPT讲稿)Agent Mobility Software Agent(主讲:余萍).pptx
- 上海师范大学:《R语言与统计分析》课程教学资源(PPT课件)R语言——介绍(主讲:汤银才).ppt
- 《视频制作》课程教学资源:课程教学大纲.doc
- 新乡学院:《办公自动化》课程教学资源(教学大纲).pdf
- 《Excel高级应用》课程教学资源:课程教学大纲.doc
- 《计算机网络》课程电子教案(PPT课件讲稿)第2章 数据通信的基础知识.ppt
- 并行处理(PPT讲稿)Parallel Processing - Hypercubes and Their Algorithms.ppt
- 《计算机网络》课程教学资源(PPT课件讲稿)第8章 应用层.ppt
- 香港城市大学:PROGRAMMING METHODOLOGY AND SOFTWARE ENGINEERING.ppt
- 《计算机操作系统》课程教学资源(PPT课件讲稿)第二章 进程描述与控制 Process Concept & Process Control.ppt
- 佛山科学技术学院:《网络技术基础》课程教学资源(专业技能考试大纲).doc
- 四川大学:《数据结构》课程教学资源(PPT课件讲稿)第五章 树和二叉树 Tree & Binary Tree.ppt
- 2019年《计算机网络》考试大纲.doc
- 计算机算法(PPT讲稿)禁忌搜索算法 Tabu Search.ppt
- 北京航空航天大学:《数据挖掘——概念和技术(Data Mining - Concepts and Techniques)》课程教学资源(PPT课件讲稿)Chapter 05 Mining Frequent Patterns, Association and Correlations.ppt
- 电子科技大学:《计算机操作系统》课程教学资源(PPT课件讲稿)第二章 进程与调度(Processes and Scheduling).ppt
- 交互式数据语言(PPT讲稿)Basic IDL knowledge.ppt
- 江苏海洋大学(淮海工学院):《Java面向对象程序设计》课程教学资源(PPT课件讲稿)全国二级Java考试的重点难点.pptx