1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
procedure main()
shared can_access_count := create_semaphore(1)
shared count := 0
create_thread(thread_a)
create_thread(thread_b)
end procedure
procedure thread_a()
wait(can_access_count)
count := count + 1
signal(can_access_count)
end procedure
procedure thread_b()
wait(can_access_count)
count := count + 1
signal(can_access_count)
end procedure