ch03 - 3. Higher-Level Synchronization 3.1 Shared Memory...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
3. Higher-Level Synchronization 3.1 Shared Memory Methods – Monitors – Protected Types 3.2 Distributed Synchronization/Comm . – Message-Based Communication – Procedure-Based Communication – Distributed Mutual Exclusion 3.3 Other Classical Problems – The Readers/Writers Problem h Di i Phil h P bl – The Dining Philosophers Problem – The Elevator Algorithm – Event Ordering with Logical Clocks CompSci 143A Spring, 2009 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3.1 Shared Memory Methods • Monitors rotected Types • Protected Types CompSci 143A Spring, 2009 2
Background image of page 2
Motivation • Semaphores and Events are: owerful but low vel abstractions Powerful but low-level abstractions • Programming with them is highly error prone • Such programs are difficult to design, debug, and maintain – Not usable in distributed memory systems • Need higher-level primitives – Based on semaphores or messages pg CompSci 143A Spring, 2009 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Monitors Follow principles of abstract data types (object-oriented programming): A data type is manipulated only by a set of predefined operations A monitor is 1. A collection of data representing the state of the source controlled by the monitor and resource controlled by the monitor, and 2. Procedures to manipulate the resource data CompSci 143A Spring, 2009 4
Background image of page 4
Monitors Implementation must guarantee: esource is nly accessible by monitor 1. Resource is only accessible by monitor procedures . onitor procedures are utually exclusive 2. Monitor procedures are mutually exclusive For coordination, monitors provide: wa it c.wait Calling process is blocked and placed on waiting queue associated with condition variable c c.signal Calling process wakes up first process on queue CompSci 143A Spring, 2009 5 associated with c
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Monitors • “condition variable” c is not a conventional variable –c has no value an arbitrary name chosen by programmer c is an arbitrary name chosen by programmer • By convention, the name is chosen to reflect the an event, state, or condition that the condition variable represents – Each c has a waiting queue associated – A process may “block” itself on c -- it waits until another process issues a signal on c CompSci 143A Spring, 2009 6
Background image of page 6
Monitors • Design Issue: – After c.signal , there are 2 ready processes: • The calling process which did the c.signal • The blocked process which the c.signal “woke up” – Which should continue? (Only one can be executing inside the monitor!) Two different approaches – Hoare monitors – Mesa-style monitors CompSci 143A Spring, 2009 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Hoare Monitors • Introduced by Hoare in a 1974 CACM aper paper • First implemented by Per Brinch Hansen in oncurrent Pascal Concurrent Pascal • Approach taken by Hoare monitor: – After c.signal , • Awakened process continues • Calling process is suspended, and placed on high- priority queue CompSci 143A Spring, 2009 8
Background image of page 8
Hoare Monitors ffect of ait Effect of signal Effect of wait Figure 3-2 CompSci 143A Spring, 2009 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bounded buffer problem monitor BoundedBuffer { har buffer[n]; char buffer[n];
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/18/2009 for the course CSE 104 taught by Professor Franklin,s during the Spring '08 term at UC Irvine.

Page1 / 46

ch03 - 3. Higher-Level Synchronization 3.1 Shared Memory...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online