# Timing of a semaphore pair.  A V is followed by a P inside a fa loop.
# The semaphore never blocks.

resource semaphore()

  sem dummy

  int  limit, factor, base, trials 

  getarg(1,factor)
  getarg(2,base)
  getarg(3,trials)
  limit = factor * base

  process test  {
    int  start, finish 
    for [ t = 1 to trials ] {
	start = age()
	for [ i = 1 to limit ] { V(dummy); P(dummy) }
	finish = age()
	printf("%d times   %d ms\n",limit,finish-start)
    }
  }

end
