[vlc-devel] [PATCH] src: darwin/thread: reimplement monotonic clock for darwin

Rémi Denis-Courmont remi at remlab.net
Mon Jan 6 21:59:37 CET 2014

Le lundi 6 janvier 2014, 21:40:01 Gilles Chanteperdrix a écrit :
> On 01/06/2014 08:10 PM, Rémi Denis-Courmont wrote:
> > Sure, nanosleep() is allowed to use the monotonic clock,
> No, nanosleep is supposed to be based on CLOCK_REALTIME, if you want to
> use CLOCK_MONOTONIC, you have to use clock_nanosleep.

Your statement is very misleading and I would even say you are wrong, 
depending on the interpretation of the word "base".

"Setting the value of the CLOCK_REALTIME clock via clock_settime() shall have 
no effect on threads that are blocked waiting for a relative time service based 
upon this clock, including the nanosleep() function; nor on the expiration of 
relative timers based upon this clock. Consequently, these time services shall 
expire when the requested relative interval elapses, independently of the new 
or old value of the clock."


In other words, nanosleep() follows the real-time clock minus the time warps. 
That is a possible and indeed the typical implementation of the monotonic 
clock on POSIX systems.

Rémi Denis-Courmont

More information about the vlc-devel mailing list