[time-nuts] FreeBSD, NetBSD, or Minix-III?

Poul-Henning Kamp phk at phk.freebsd.dk
Mon May 18 13:32:33 UTC 2009


In message <C636B079.7D49%James.P.Lux at jpl.nasa.gov>, "Lux, James P" writes:

>An integer divide in software is quite fast
>(unless you're working with something like a Z80).

You only need to divide when you want to change your estimate of the
counters range, for generating timestamps a multiplication will do.

>There's no real advantage in having "hardware" count seconds.. It takes more
>gates to count by arbitrary N than 2^M. 

Not only that, it makes the calculation of timeintervals as differences
between two timestamps a royal mess:

#define timersub(tvp, uvp, vvp)                                         \
        do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
                if ((vvp)->tv_usec < 0) {                               \
                        (vvp)->tv_sec--;                                \
                        (vvp)->tv_usec += 1000000;                      \
                }                                                       \
        } while (0)

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.




More information about the Time-nuts_lists.febo.com mailing list