MODULETimePosix EXPORTSTime ,TimePosix ; IMPORT Utime; PROCEDURENow (): T = VAR tv: Utime.struct_timeval; i := Utime.gettimeofday(tv); BEGIN <* ASSERT i=0 *> RETURN FromUtime(tv); END Now; PROCEDUREToUtime (n: T): Utime.struct_timeval= VAR tv: Utime.struct_timeval; BEGIN tv.tv_sec := TRUNC(n); tv.tv_usec := ROUND((n - FLOAT(tv.tv_sec, LONGREAL)) * 1.0D6); RETURN tv; END ToUtime; PROCEDUREFromUtime (READONLY tv: Utime.struct_timeval): T= BEGIN RETURN FLOAT(tv.tv_sec, LONGREAL) + FLOAT(tv.tv_usec, LONGREAL) / 1.0D6 END FromUtime; VAR t0, t1: T; BEGIN (* Determine value of "Grain" experimentally. Note that this will fail if this thread is descheduled for a tick during the loop below. *) t0 := Now(); REPEAT t1 := Now() UNTIL t1 # t0; Grain := t1-t0 END TimePosix.