@@ -1,4 +1,13 @@
|
|
1 |
-
procedure main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
print "Hello from main thread of process ", process_number, " of " \
|
3 |
, process_count, " on ", process_hostname
|
|
|
4 |
end procedure
|
1 |
+
procedure main:
|
2 |
+
declare const previous_process = \
|
3 |
+
(process_count + process_number - 1) % process_count
|
4 |
+
declare const next_process = (process_number + 1) % process_count
|
5 |
+
declare can_print := true
|
6 |
+
|
7 |
+
if process_number > 0 then
|
8 |
+
receive(&can_print, 1, previous_process)
|
9 |
+
end if
|
10 |
print "Hello from main thread of process ", process_number, " of " \
|
11 |
, process_count, " on ", process_hostname
|
12 |
+
send(can_print, 1, next_process)
|
13 |
end procedure
|