Messages in this thread | | | Date | Mon, 23 Jun 2008 11:48:00 +0200 | From | "Michael Kerrisk" <> | Subject | Re: nanosleep() uses CLOCK_MONOTONIC, should be CLOCK_REALTIME? |
| |
Bart,
On Mon, Jun 23, 2008 at 10:34 AM, Bart Van Assche <bart.vanassche@gmail.com> wrote: > On Sun, Jun 22, 2008 at 9:35 AM, Michael Kerrisk <mtk.manpages@gmail.com> wrote: >> Thomas, >> >> (I gues you are the right target for this?) >> >> The POSIX.1 specification of nanosleep() says: >> >> But, except for the case of being interrupted by a signal, the >> suspension time shall not be less than the time specified by >> rqtp, as measured by the system clock CLOCK_REALTIME. >> >> >> However, reading kernel/hrtimer.c:sys_nanosleep(), it appears that >> CLOCK_MONOTONIC is used. >> >> return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC); >> >> Is there a reason to use CLOCK_MONOTONIC, instead of CLOCK_REALTIME? Is it >> intentional? If yes, then I should document this in the man-pages. If not, >> then it should be fixed. > > CLOCK_MONOTONIC works fine even if ntpd steps the clock forward or > backward, CLOCK_REALTIME not. So the man page should be fixed.
Thanks for your reply, but I'm not quite convinced yet. The things is: the Solaris man page also says "CLOCK_REALTIME". (Of course that man page may just be parroting the standard.) Could there not be some reasonable semantics for a nanosleep() that was based on CLOCK_REALTIME?
Thanks,
Michael
-- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
| |