@@ -1,12 +1,11 @@
|
|
1 |
main:
|
2 |
-
shared
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
thread_b:
|
11 |
-
wait(a1_ready)
|
12 |
-
statement b1
|
1 |
main:
|
2 |
+
shared thread_count := read_integer()
|
3 |
+
shared ready[]
|
4 |
+
for index := 0 to thread_count do
|
5 |
+
ready[index] := semaphore(not index)
|
6 |
+
create_thread(1, secondary, index)
|
7 |
|
8 |
+
secondary(rank):
|
9 |
+
wait(ready[rank])
|
10 |
+
statement s1
|
11 |
+
signal(ready[(rank + 1) % thread_count])
|
|
|
|
|
|