01.06.2014 Views

Concurrent Systems II - Bad Request - Trinity College Dublin

Concurrent Systems II - Bad Request - Trinity College Dublin

Concurrent Systems II - Bad Request - Trinity College Dublin

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Attempt #3 Shortened<br />

loop forever<br />

Critical Section Problem Attempt #3<br />

boolean wantp ← false, wantq ← false<br />

p<br />

loop forever<br />

p1: wantp ← true q1: wantq ← true<br />

p2: await wantq = false q2: await wantp = false<br />

p3: wantp ← false q3: wantq ← false<br />

q<br />

Process p Process q wantp wantq<br />

p1: non critical section q1: non critical section FALSE FALSE<br />

p2: wantp ← true q1: non critical section FALSE FALSE<br />

p2: wantp ← true q2: wantq ← true FALSE FALSE<br />

p3: await wantq = false q2: wantq ← true TRUE FALSE<br />

p3: await wantq = false q3: await wantp = false TRUE TRUE<br />

114<br />

<strong>Trinity</strong> <strong>College</strong> <strong>Dublin</strong><br />

© Mike Brady 2007–2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!