Lecture18 - COP 4600 Operating Systems Fall 2010 Click to...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style 8/1/11 Lecture 18 COP 4600 Operating Systems Fall 2010 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture 18 8/1/11 n Last time: n Presentation of “Distributed object model” of Java by Waldo et al. n More on processor switching n Deadlocks n Implementation of a communication channel as a bounded buffer. n Race conditions n Today: n Thread coordination with a bounded buffer. n Question and answer session for the midterm. ¨ Next time n Midterm Lecture 18 – Tuesday October 21, 2010 22
Background image of page 2
Lecture 18 8/1/11 1 2 N-1 N-2 out in Read from the buffer location pointed by out Write to the buffer location pointed by out shared structure buffer message instance message[N] integer in initially 0 integer out initially 0 procedure SEND (buffer reference p, message msg) while p.in – p.out = N do nothing /* if buffer full wait p.message [p.in modulo N] ß msg /* insert message into buffer cell p.in ß p.in + 1 /* increment pointer to next free cell RECEIVE (buffer p) while p.in = p.out /* if buffer empty wait for message msg ß p.message [p.in modulo N] /* copy message from buffer cell p.out ß p.out + 1 /* increment pointer to next message return msg 0 33
Background image of page 3

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

View Full DocumentRight Arrow Icon
Lecture 18 8/1/11 Implicit assumptions for the correctness of the implementation 1. One sending and one receiving thread. Only one thread updates each shared variable. 2. Sender and receiver threads run on different processors& to allow spin locks 3. in and out are implemented as integers large enough so that they do not overflow (e.g., 64 bit integers) 4. The shared memory used for the buffer provides read/write coherence 5. The memory provides before-or-after atomicity for the shared variables in and out 6.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

Lecture18 - COP 4600 Operating Systems Fall 2010 Click to...

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

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