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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Temporal logic at work<br />

• Consider some safety and liveness properties for our solutions to the<br />

critical section problem:<br />

Critical section problem – Dekker’s algorithm<br />

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

integer turn ← 1<br />

loop forever<br />

p1: non-critical section<br />

p2: wantp ← true<br />

p3:<br />

p4:<br />

while wantq<br />

if turn = 2<br />

p5: wantp ← false<br />

p6: await turn = 1<br />

p7: wantp ← true<br />

p8: ><br />

p9: turn ← 2<br />

p10: wantp ← false<br />

p<br />

loop forever<br />

q1: non-critical section<br />

q2: wantq ← true<br />

q3:<br />

q4:<br />

while wantp<br />

if turn = 1<br />

q5: wantq ← false<br />

q6: await turn = 2<br />

q7: wantq ← true<br />

q8: ><br />

q9: turn ← 1<br />

q10: wantq ← false<br />

q<br />

• Mutual exclusion (safety)?<br />

• Freedom from starvation for p (liveness)?<br />

• Freedom from deadlock (liveness)?<br />

3BA29/3D4 <strong>Concurrent</strong> <strong>Systems</strong> and Operating <strong>Systems</strong><br />

http://www.cs.tcd.ie/Stephen.Childs childss@cs.tcd.ie

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

Saved successfully!

Ooh no, something went wrong!