- 61 Views
- Uploaded on
- Presentation posted in: General

Midterm

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Midterm

P1: P2: P3:

x = 1y = 1z = 1

P3 ! x - 1 ------------------------------------------------>P1 ? z

{A1: x = 1 } { C1: z= 0 /\ x = 1}

P3 ? y<----------------------P2 ! z + 1

{B1: y = 1 /\ z = 0} {C2: z= 0 /\ y = 1}

y = y + 1

{B2: y = 2}

P2 ? x <--------------P1 ! y

{A2: x = 2/\ y = 2} {B3: y = 2 /\ x = 2}

Producer:Consumer:

do do

wait for a slot to be empty wait until a slot is non-empty

deposit item in the empty slot fetch item from a non-empty slot

odod

Producer:Consumer:

do do

in1++ in2++

deposit item in the empty slot fetch item from a non-empty slot

out1++ out2++

odod

in1 <= out2 + 2 /\ in2 <= out1

in1 <= out2 + out3 + 2 /\ in2 + in3 <= out1

{x = y}

co

{ x = y \/ y = x + 3}

< x = x + 2>

{x = y + 2 \/ y = x + 1}

||

{ x = y \/ x = y + 2}

< y = y + 3>

{ x + 3 = y \/ x + 1 = y>

oc

{ y = x + 1}