@@ -1,9 +1,12 @@
|
|
1 |
procedure main()
|
2 |
input const skater_count, const room_capacity
|
|
|
3 |
create_threads(skater_count, skater)
|
4 |
end procedure
|
5 |
|
6 |
procedure skater()
|
7 |
// Concurrency-bounded region
|
|
|
8 |
skate()
|
|
|
9 |
end procedure
|
1 |
procedure main()
|
2 |
input const skater_count, const room_capacity
|
3 |
+
shared can_skate := create_semaphore(room_capacity)
|
4 |
create_threads(skater_count, skater)
|
5 |
end procedure
|
6 |
|
7 |
procedure skater()
|
8 |
// Concurrency-bounded region
|
9 |
+
wait(can_skate)
|
10 |
skate()
|
11 |
+
signal(can_skate)
|
12 |
end procedure
|