[PATCH_v2] use CLOCK_MONOTONIC_COARSE posix timer instead of CLOCK_MONOTONIC in Xorg

ykzhao yakui.zhao at intel.com
Fri Aug 27 02:32:55 PDT 2010


On Fri, 2010-08-27 at 10:15 +0800, Daniel Stone wrote:
> On Fri, Aug 27, 2010 at 09:20:59AM +0800, yakui.zhao at intel.com wrote:
> >    Limit the CLOCK_MONOTONIC_COARSE posix timer to linux platform. This is
> > to avoid the issue that OS doesn't support CLOCK_MONOTINC_COARSE posix timer
> > while the corresponding clock id is for other purpose. At the same time it
> > won't be created if the CLOCK_MONOTONIC_COARSE is defined in system header
> > file.
> 
> ... what?? CLOCK_MONOTONIC_COARSE _always_ means the coarse monotonic
> clock if defined, on any platform.  It's always safe to use.

Do you mean that it is safe to use the coarse monotonic clock if it is
defined? Right?

But in the discussion of V1 version, it seems that it is not reasonable
for other OS. Maybe the CLOCK_MONOTONIC_COARSE posix timer is not
supported. But the corresponding clock id is used for other purpose. In
such case it will be not safe.

> 
> Your patch, however, removes the check to make sure the monotonic clock
> is working.  

No. The CLOCK_MONOTONIC check is not removed. It is realized by using:
   >if (clock_gettime(clockid, &tp) == 0)
   If it fails, it will then call the function of gettimeofday.
   
   When the CLOCK_MONOTONIC_COARSE is not supported or the resolution of
timer is greater than 1ms, it will fall back to CLOCK_MONOTONIC. 

If you expect to do more check about CLOCK_MONOTONIC, Maybe we can add
another patch to check it. 

> Just take the patch I posted previously, make sure it
> works, and probably also add a check that
> clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) actually works, similar to
> the check for CLOCK_MONOTONIC.

It is not wrong if we also add the check of clock_gettime for
CLOCK_MONOTONIC_COARSE posix timer. But IMO it will be redundant.

One posix timer at least provides the following two function. One is to
get the corresponding timer and the other is to get the resolution. The
clock_getres() can do the similar check witch the function of
clock_gettime. 

Thanks.
   Yakui
> 
> Cheers,
> Daniel



More information about the xorg-devel mailing list