电子科技大学计算机操作系统课件Chapter 2 Processes and Scheduling (II).pptVIP

  • 8
  • 0
  • 约3.8万字
  • 约 140页
  • 2019-05-06 发布于广东
  • 举报

电子科技大学计算机操作系统课件Chapter 2 Processes and Scheduling (II).ppt

Chapter 2 Processes and Scheduling (II) Mutual Exclusion and Synchronization Principles of concurrency. Mutual Exclusion: Software approaches and Hardware Support. Semaphores、Monitors、Message Passing. Tradition question: Producer/Consumer、Readers/Writers Problem. Difficulties Arise in Concurrency Types: interleaving and overlapping. The sharing of global resources is fraught with peril. It is difficult for the OS to manage the allocation of resources optimally. It is difficult to locate a programming error, because results are typically not reproducible. Sharing can lead to problems Process P1 . input (in, keyboard) . out:=in output (out, display) . . Problems of Concurrent Resource competition: How to allocate the resource, and how to mutual exclusion access the critical resources. Execution sequence. Communication cooperation. Process Interaction (table5.1) Processes unaware of each other: OS needs to be concerned about competition for resources. Exp. Two independent applications may both want access to the same disk or file or printer. Processes indirectly aware of each other(e.g., shared object): The processes share access to some object such as I/O buffer. Processes directly aware of each other: Communicate with each other by name. Mutual Exclusion(P193) Critical resource: Only one process can access it at a time. Critical section:the portion of the program that uses critical resource. P194,fig5.1 Program mutualexclusion Const n-…; (*num of processes) Procedure P(i:integer) Begin repeat enter critical(R) critical section; exit critical(R) remainder forever End; Deadlock and Starvation(P194) Deadlock Exp. Two processes P1、P2, both request to resource R1、R2. At a time: P1 gets R2 and P2 gets R1, in the meantime P1 requests R1 and P2 requests R2 Then P1 and P2 wait for each other forever deadlock. Starvation P1 always communication with P2, p3 is starved. Cooperation among Processes by Sharing(p195) Data integrity Reading and writing

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档