@@ -1,16 +1,25 @@
|
|
1 |
procedure main:
|
2 |
-
declare
|
3 |
-
declare
|
4 |
-
"Hello from main thread of process " + process_number \
|
5 |
-
+ " of " + process_count + " on " + process_hostname
|
6 |
|
7 |
-
if process_number
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
end
|
|
|
|
|
|
|
|
|
15 |
end if
|
|
|
|
|
|
|
|
|
16 |
end procedure
|
1 |
procedure main:
|
2 |
+
declare values as a dynamic array of float
|
3 |
+
declare value_count := 0
|
|
|
|
|
4 |
|
5 |
+
if process_number = 0 then
|
6 |
+
declare value := 0
|
7 |
+
while can_read(stdin) do
|
8 |
+
append(values, value)
|
9 |
+
end while
|
10 |
+
|
11 |
+
value_count := count(values)
|
12 |
+
for target := 1 to process_count do
|
13 |
+
send(&value_count, 1, target)
|
14 |
+
send(&values, count(values), target)
|
15 |
end
|
16 |
+
else
|
17 |
+
receive(&value_count, 1, 0)
|
18 |
+
resize(values, value_count)
|
19 |
+
receive(&values, value_count, 0)
|
20 |
end if
|
21 |
+
|
22 |
+
for index := 0 to count(values) do
|
23 |
+
print(process_number, ": ", index, ": ", values[index])
|
24 |
+
end for
|
25 |
end procedure
|