COS226 - Lecture - Mutual Exclusion - 2

COS226 - Lecture - Mutual Exclusion - 2 - A j → CS B k...

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

View Full Document Right Arrow Icon
COS226: Concurrent Systems Chapter 2: Mutual Exclusion Part 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
LockOne Proof Lemma 2.3.1: The LockOne algorithm satisfies mutual exclusion. Proof: Suppose not. Then there exist integers j and k such that CS A j → CS B k and CS B k CS A j . Consider each thread's last execution of the lock() method before entering its k th (j th ) critical section.
Background image of page 2
LockOne Proof write A (flag[A] = true) → read A (flag[B] == false) → CS A (2.3.1) write B (flag[B] = true) → read B (flag[A] == false) → CS B (2.3.2) read A (flag[B] == false) → write B (flag[B] = true) (2.3.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
LockOne Proof write A (flag[A] = true) read A (flag[B] == false) write B (flag[B] = true) read B (flag[A] == false)
Background image of page 4
LockTwo Proof Lemma 2.3.2 The LockTwo algorithm satisfies mutual exclusion. Proof: Suppose not. Then there exist integers j and k such that CS
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: A j → CS B k and CS B k → CS A j . Consider each thread's last execution of the lock() method before entering its k th (j th ) critical section. LockTwo Proof write A (victim = A) → read A (victim == B) CS → A (2.3.5) write B (victim = B) → read B (victim == A) CS → B (2.3.6) LockTwo Proof write A (victim = A) → write B (victim = B) → read A (victim = B) (2.3.7) The Peterson Lock class Peterson implements Lock { private boolean flag = new boolean[2]; private int victim; The Peterson Lock public void lock() { int i = ThreadID.get(); int j = 1 – i; flag[i] = true; victim = i; while (flag[j] && victim == i) {} } The Peterson Lock public void unlock() { int i = ThreadID.get(); flag[i] = false; }...
View Full 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 / 10

COS226 - Lecture - Mutual Exclusion - 2 - A j → CS B k...

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

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