[PATCH xserver 2/4] os: Use separate clockid for GetTimeInMicros()

Jeffrey Smith whydoubt at gmail.com
Wed Dec 27 22:22:01 UTC 2017


On Wed, Dec 27, 2017 at 1:26 PM, Keith Packard <keithp at keithp.com> wrote:
> Jeff Smith <whydoubt at gmail.com> writes:
>
>> Prior to commit a779fda2 (xwayland: Use the CLOCK_MONOTONIC clock),
>> GetTimeInMillis() and GetTimeInMicros() had separate clockid's.  As a
>> part of making them available to ForceClockId(), that commit replaced
>> them with a single clockid, whose value depended on which GetTime
>> function got called first.
>
> Hrm. I would think that it would be good to have both paths always
> select the same clock; is there some reason we can't have
> GetTimeInMillis just call GetTimeInMicros and divide by 1000?

GetTimeInMillis uses the CLOCK_MONOTONIC_COARSE clock if
available and the precision is high enough.  That clock is supposed
to be more efficient to query than CLOCK_MONOTONIC (at the cost
of being less precise).  So implementing GetTimeInMillis by calling
GetTimeInMicros could mean spending extra time to get higher
precision, just to spend more time (for the division) throwing it away.

> I think the only reason for prefering milliseconds is that it's easier
> on 32-bit hardware, yes?

The X base protocol and Xlib use millisecond granularity, and
GetTimeInMillis is used in updating the xserver's global currentTime
value which also uses millisecond granularity.

> --
> -keith


More information about the xorg-devel mailing list