03.05.2013 Views

Concurrency en race condities

Concurrency en race condities

Concurrency en race condities

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Afscherming voor N tak<strong>en</strong> met arbiter<br />

(Luuk Gro<strong>en</strong>eweg<strong>en</strong>)<br />

<strong>en</strong>um KRITIEK {erin, eruit} IkWil[Nproc], JeMag[Nproc];<br />

Cli<strong>en</strong>t(int N)<br />

{ while(1)<br />

{ /* Niet kritiek */<br />

IkWil[N] = erin;<br />

wachtop(JeMag[N] == erin);<br />

/* kritiek */<br />

IkWil[N] = eruit;<br />

wachtop(JeMag[N] ==<br />

eruit);<br />

}<br />

}<br />

Arbiter()<br />

{ i = 0;<br />

while(1)<br />

{<br />

if (IkWil[i] == erin)<br />

{ JeMag[i] = erin;<br />

wachtop(IkWil[i] ==<br />

eruit);<br />

JeMag[i] = eruit;<br />

}<br />

i = (i + 1) % Nproc;<br />

}<br />

}<br />

College OS 2010 – 2011 14

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

Saved successfully!

Ooh no, something went wrong!