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