COS226 - Lecture - Mutual Exclusion - 1

COS226 - Lecture - Mutual Exclusion - 1 - COS226 Concurrent...

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

View Full Document Right Arrow Icon
COS226: Concurrent Systems Chapter 2: Mutual Exclusion Part 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
Time A thread is a state machine and its state transitions are called events ; Events are instantaneous and never simultaneous ;
Background image of page 2
Time A thread A produces a sequence of events, a 0 ,a 1 ,... The j th occurrence of event a i is denoted as a i j ; An event a precedes event b, a → b, if it occurs at an earlier time.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Time Let a 0 and a 1 be events such that a 0 → a 1 ; An interval (a 0 ,a 1 ) is the duration between a 0 and a 1 ; Interval I A = (a 0 ,a 1 ) precedes I B = (b 0 ,b 1 ), I A → I B , if a 1 → b 0 ; Intervals that are unrelated by → are said to be concurrent. The j th execution of I A is denoted I A j .
Background image of page 4
Critical Sections public long getAndIncrement() { long temp = value; value = temp + 1; return temp; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Critical Sections public interface Lock { public void lock(); public void unlock(); }
Background image of page 6
Critical Sections public class Counter { private Lock lock; public long getAndIncrement() { lock.lock(); try { long temp = value; value = temp + 1; } finally { lock.unlock(); } return temp; }
Background image of page 7

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

View Full DocumentRight Arrow Icon
Critical Sections mutex.lock(); try { // body } finally { mutex.unlock(); }
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/11/2010 for the course COS COS226 taught by Professor Klazar during the Spring '10 term at University of Pretoria.

Page1 / 17

COS226 - Lecture - Mutual Exclusion - 1 - COS226 Concurrent...

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

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