02.04.2013 Views

CONTENTS

CONTENTS

CONTENTS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

246 ERNEST SCHEIBER (1)<br />

Algorithm 2 The dispatcher procedure.<br />

1: procedure Dispatcher<br />

2: Data structures: Stack repository;<br />

3: boolean[ ]freeW orker1≤i≤size<br />

4: send messages number ← 0<br />

5: received messages number ← 0<br />

6: for i = 1 : size do<br />

7: freeW orkeri ← true<br />

8: end for<br />

9: Specific initializations of the application<br />

10: Send an ordinary-message to the W orker1<br />

11: freeW orker1 ← false<br />

12: send messages number ← send messages number + 1<br />

13: while repository is not empty or<br />

14: send messages number = received messages number do<br />

15: if send messages number = received messages number then<br />

16: Receive a response message<br />

17: received messages number ← received messages number + 1<br />

18: freeW orkersender−rank ← true<br />

19: Process the received message<br />

20: end if<br />

21: while exists free Workers and the repository is not empty do<br />

22: Extracts an object from the repository<br />

23: Sends an ordinary-message to a free Worker<br />

24: freeW orkerreceiver−rank ← false<br />

25: send messages number ← send messages number + 1<br />

26: end while<br />

27: end while<br />

28: for i = 1 : size do<br />

29: Sends Ending-type-message to the W orkeri<br />

30: end for<br />

31: end procedure<br />

If the worker receives the sequence [x0, x1, . . . , xk−1] (k − 1 < n) with xp ∈<br />

{0, 1, . . . , n − 1} and<br />

(1) xp = xq and |xp − xq| = |p − q| ∀p, q ∈ {0, 1, . . . , k − 1},<br />

then it executes the following operations:<br />

1: for any i ∈ {0, 1, . . . , n − 1} do<br />

2: It verifies the validity conditions (1) of the sequence [x0, x1, . . . , xk−1, i].

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

Saved successfully!

Ooh no, something went wrong!