Mutual Exclusion and Synchronization s Principles of concurrency Mutual Exclusion: Software approaches and hardware Support. ☆ Semaphores、 Monitors、 Message passing Tradition question: Producer/Consumer, Readers/Writers Problem PROCESSES AND SCHEDULING
PROCESSES AND SCHEDULING 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 s Types: interleaving and overlapping The sharing of global resources is fraught with e 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. PROCESSES AND SCHEDULING
PROCESSES AND SCHEDULING 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 Process P2 input (in, keyboard) input(in, keyboard) out:=in out: =in output (out, display output (out, display) So, it is necessary to protect shared global variables PROCESSES AND SCHEDULING
PROCESSES AND SCHEDULING Sharing can lead to problems Process P1 . input (in, keyboard) . out:=in output (out, display) . . Process P2 . input (in, keyboard) . out:=in output (out, display) . . So, it is necessary to protect shared global variables
Problems of concurrent Resource competition: How to allocate the resource and how to mutual exclusion access the critical resources 令 Execution sequence .o Communication cooperation PROCESSES AND SCHEDULING
PROCESSES AND SCHEDULING 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(tables1) 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 s Processes indirectly aware of each other(e.g, shared object): The processes share access to some object such as wo buffer Processes directly aware of each other: Communicate with each other by name. PROCESSES AND SCHEDULING
PROCESSES AND SCHEDULING 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