[lkml]   [2012]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: clock_getres() and real resolution
On 02/09/2012 02:12 AM, Thomas Gleixner wrote:

> It would be possible to return the real resolution of the clock event
> device, but we have systems, where the clockevent device is
> dynamically changing. So which resolution do we expose to an
> application? The one of the current active device or some magic number
> of a device which might not even be initialized? That's more confusing
> than telling user space that high resolution timers are active and the
> kernel is trying to achieve the 1ns accuracy.

First of all, it's not necessary to make unrealizable promises to
an application programmer. If it's known that _any_ hardware configuration
can't guarantee, for example, <20ns precision, it's better to return
{0, 20} than {0, 1} from clock_getres(...). If high-res subsystem
isn't active, just return -1 and set errno to EINVAL, regardless of
an arguments passed.

Second, it's very hard to deny that some applications really needs
precise time measurements. So, if the clockevent device is dynamically
changing, it would be nice to have a method to prevent the loss of
precision for such an application. For example, an application may
issue prctl(PR_SET_CLOCK_STABLE, 1) to make sure that hrtimer's resolution
isn't changed (or at least not changed with the loss of precision)
until prctl(PR_SET_CLOCK_STABLE, 0) or exit(); if some system-wide
event decreases hrtimer accuracy, such an application might receive
a signal, etc.


 \ /
  Last update: 2012-02-09 16:27    [W:0.077 / U:0.288 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site