#INCLUDE "semaphore.inc"

#INCLUDE "display.inc"

PROC timekeeper (CHAN OF DISPLAY out, SEMAPHORE out.s)

  VAL INT second IS 1000000:

  TIMER tim:
  INT t:

  INT count:

  SEQ

    count := 0
    tim ? t

    WHILE TRUE
      SEQ
        claim.semaphore (out.s)
        out ! time; count
        release.semaphore (out.s)
        count := count PLUS 1
        t := t PLUS second
        tim ? AFTER t

:
