Download c source code

shared count := 0

main:
  thread_count := read_integer()
  upper_limit := read_integer();
  shared multiplex := semaphore(upper_limit)
  create_thread(secondary, thread_count)

secondary:
  wait(multiplex)
  count := count + 1
  signal(multiplex)