Yes, you're correct. In glibc 2.44, time() uses a macro which is defined as CLOCK_REALTIME_COARSE.

The definition of gettimeofday(), on the other hand, refers directly to CLOCK_REALTIME, just as you note.

On 8/19/26 13:43, Ian Collier via Mutt-dev wrote:
On Wed, Aug 19, 2026 at 07:01:59PM +0200, Steffen Nurpmeso wrote:
Musl impl is
   #include "syscall.h"

   time_t time(time_t *t)
   {
           struct timespec ts;
           __clock_gettime(CLOCK_REALTIME, &ts);
           if (t) *t = ts.tv_sec;
           return ts.tv_sec;
   }

I believe glibc uses CLOCK_REALTIME_COARSE in that syscall (but
CLOCK_REALTIME for the gettimeofday(2) function).

If I understand correctly, CLOCK_REALTIME asks the clock hardware
whereas CLOCK_REALTIME_COARSE fetches a stored value that is updated
once per jiffy.

On modern systems HZ=1000, but my testing showed a delay of up to 1.53ms
on x86_64 and 1.08ms on arm64.

Ian Collier.

Reply via email to