taskc/signaling/{signaling.alg.c → signaling_w.alg.c} RENAMED
@@ -1,12 +1,11 @@
1
  main:
2
- shared a1_ready := semaphore(0)
3
- create_thread(thread_a)
4
- create_thread(thread_b)
 
 
5
 
6
- thread_a:
7
- statement a1
8
- signal(a1_ready)
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])