{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COS226 - Lecture - Mutual Exclusion - 2

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

Info icon This 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
Image of page 1

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

View Full Document Right 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.
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)
Image of page 3

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

View Full Document Right Arrow Icon
LockOne Proof write A (flag[A] = true) read A (flag[B] == false) write B (flag[B] = true) read B (flag[A] == false)
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
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern