[comp.unix.wizards] setitimer

tcjones@watdragon.waterloo.edu (Crocodile Dundee) (01/18/88)

I was wondering if there were people out there who know the details of
setitimer/getitimer. I know how to work them and all that, but the figures I
get seem very inconsistent. Does anyone know what happens if a timer expires
and you do not have the CPU at the time? What if another timer then expires
before you get the CPU? What sort of resolution can one reasonably expect? I
never seem to get anything better than 100ths of seconds accuracy.

I am on a VAX 8650 under BSD4.3
Thanks.


Terry Jones

-------------------------------------------------------------------------------
Department Of Computer Science, University Of Waterloo
Waterloo Ontario Canada N2L 3G1

{ihnp4,allegra,decvax,utzoo,utcsri,clyde}!watmath!watdragon!tcjones
tcjones@dragon.waterloo.{cdn,edu} tcjones@WATER.bitnet
tcjones%watdragon@waterloo.csnet [from oz, tcjones@dragon.waterloo.cdn@munnari]
-------------------------------------------------------------------------------

chris@mimsy.UUCP (Chris Torek) (01/20/88)

In article <4672@watdragon.waterloo.edu> tcjones@watdragon.waterloo.edu
(Crocodile Dundee) writes:
>... the figures I get seem very inconsistent. Does anyone know what
>happens if a timer expires and you do not have the CPU at the time?

It depends on the kind of timer.  Of course, the only kind that
expires when your process is not running is the real timer, but
the others could expire just before your process is switched out.
The real timer keeps ticking, reloaded from its it_interval.

>What if another timer then expires before you get the CPU?

You get a single interrupt, just like the Vax hardware clock.

>What sort of resolution can one reasonably expect?

No better than the basic kernel clock, which runs at `HZ' hertz.

>I never seem to get anything better than 100ths of seconds accuracy.
>I am on a VAX 8650 under BSD4.3

4.3BSD runs with HZ=100.  There are some provisions for an alternate
profiling clock, but I have never had a chance to experiment with
it, and it does not affect the real and virtual interval timers,
at least.

gettimeofday(), however, provides more resolution in 4.3BSD, by
reading the interval count register and inferring microseconds to
add to its ten-millisecond current time value.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris