@@ -1,14 +1,20 @@
|
|
1 |
procedure main()
|
|
|
|
|
2 |
create_thread(thread_a)
|
3 |
create_thread(thread_b)
|
4 |
end procedure
|
5 |
|
6 |
procedure thread_a()
|
7 |
statement a1
|
|
|
|
|
8 |
statement a2
|
9 |
end procedure
|
10 |
|
11 |
procedure thread_b()
|
12 |
statement b1
|
|
|
|
|
13 |
statement b2
|
14 |
end procedure
|
1 |
procedure main()
|
2 |
+
shared a1_ready := create_semaphore(0)
|
3 |
+
shared b1_ready := create_semaphore(0)
|
4 |
create_thread(thread_a)
|
5 |
create_thread(thread_b)
|
6 |
end procedure
|
7 |
|
8 |
procedure thread_a()
|
9 |
statement a1
|
10 |
+
signal(a1_ready)
|
11 |
+
wait(b1_ready)
|
12 |
statement a2
|
13 |
end procedure
|
14 |
|
15 |
procedure thread_b()
|
16 |
statement b1
|
17 |
+
signal(b1_ready)
|
18 |
+
wait(a1_ready)
|
19 |
statement b2
|
20 |
end procedure
|