1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
shared count := 0
shared multiplex
main:
upper_limit := read_integer()
multiplex := semaphore(upper_limit)
thread_count := read_integer()
create_thread(secondary, thread_count)
secondary:
wait(multiplex)
// Critical section
count := count + 1
signal(multiplex)