This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 05/10] Use clock_gettime to implement time.


* Paul Eggert:

> Florian Weimer wrote:
>> time can definitely return the
>> value of a variable that is incremented periodically from the timer
>> interrupt.
>
> Is that variable the one that CLOCK_REALTIME_COARSE uses? If so, and
> if we're going to replace calls to 'time' with calls to
> 'clock_realtime', we can do either of the following:
>
> * Use CLOCK_REALTIME_COARSE. This takes less CPU time and its behavior
> better matches what the current glibc does.
>
> * Use CLOCK_REALTIME. This will lessen bugs due to naive code (quite
> possibly some code within glibc!) which assumes that 'time (0)' and
> clock_gettime (CLOCK_REALTIME, ...)' use the same clock.

I think we should keep using the time entry in the vDSO.  This
consolidation is just not possible to do for performance reasons.

> It sounds you're leaning towards (1) and I'm inclined to
> agree. However, shouldn't the manual say that 'time' does not
> necessarily agree with CLOCK_REALTIME? The current behavior is a trap
> for the unwary.

Yes, clarifying the manual would make sense.  I do not know where the
discrepancy comes from.  It could just be that CLOCK_REALTIME performs
rounding, while time performs truncation.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]