tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Clarification of CLOCK_MONOTONIC



JJ <x85729201kza%outlook.com@localhost> writes:

> Hi all,
>
> A "simple" question about CLOCK_MONOTONIC.
>
> How does this behave under sleep states? See clock_gettime(2) or
> clock_getres(2)
>
> For example, in FreeBSD (per the manual page), it states:
>
> "Increments in SI seconds, even while the system is suspended.
> Its epoch is unspecified. The count is not adjusted by leap seconds."
>
> NetBSD makes no such pronouncement.

FreeBSD is simply (and reasonably) paraphrasing POSIX:

  https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html

The NetBSD man page doesn't say this clearly.   It's a fair question
what the behavior is, and either way, the man page should be clarified
(to say it doesn't meet POSIX, or to point out POSIX and say it meets it
even under susspend/resume).

> In code, for say, Linux kernel I would use CLOCK_BOOTTIME because it
> is aware of suspension yet CLOCK_MONOTONIC is not.

If Linux's CLOCK_MONOTONIC does not increase across suspension, then I
would say it does not comply with POSIX and should be fixed.  I might be
off here, not having passed the POSIX Language Lawyer bar exam.


Home | Main Index | Thread Index | Old Index