Date: Fri, 03 Nov 2000 19:21:21 +0100 From: Poul-Henning Kamp <phk@critter.freebsd.dk> To: Zhiui Zhang <zzhang@cs.binghamton.edu> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: granularity of gettimeofday() Message-ID: <1581.973275681@critter> In-Reply-To: Your message of "Fri, 03 Nov 2000 13:01:17 EST." <Pine.SOL.4.21.0011031255360.118-100000@jade>
next in thread | previous in thread | raw e-mail | index | archive | help
>> >The time may be updated continuously or in clock ticks. Can anyone >> >explain for me the two different ways of updating the time? What kind of >> >hardware can help? >> >> You probably need to tell me what you need first... > >This is actually a question from the book "Kernel Project for Linux" and I >am a TA for an operating system course that uses this textbook. I know a >little bit of NTP and Intel Time stamp counter. I need an authoritive >answer for this question because I do not have the time to go through the >FreeBSD code to find out myself in a short time. My impression is that if >the time is updated by an interrupt handler per tick, it can not get a >microsecond granularity. The short answer is: FreeBSD returns a continous timescale. The long answer is: FreeBSD can deliver time with a resolution of 1/2^32 nanosecond = 232.8E-21 seconds. The actual resolution is much worse, because the hardware usually doesn't provide any better than about a nanosecond at best these days. On certain hardware only about a microsecond of actual resolution is available. The frequency model operates at a similar resolution. A timestamp is based in the current value of a chosen hardware counter at the time you ask for it, we don't rely on interrupts to tell us what time it is. Experiments in the lab have proved these claims to be true for currently available hardware. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1581.973275681>