Fix thread wait to be resilient to real time clock changes on Unix (#11213)
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 26 Apr 2017 13:48:20 +0000 (06:48 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2017 13:48:20 +0000 (06:48 -0700)
commita5a8c6cdc6e3b732fc5a344878b165f149d99729
tree2131c4a28caca300a6cef99d529a734699f52348
parentd3d2efd166c408d59cde076c674fd140e7313e4d
Fix thread wait to be resilient to real time clock changes on Unix (#11213)

This change fixes a problem that happens when a thread uses a timed wait
and the real time clock change in the system (e.g. due to the user action,
time server sync, leap second, etc). In such case, the wait may end up waiting
for shorter or longer period of time.
It fixes the issue for Thread.Sleep and timed wait on a process local synchronization
primitives by using CLOCK_MONOTONIC instead of CLOCK_REALTIME for waiting on
cond vars.
Unfortunately, the waits on cross process synchronication primitives like
named mutexes always use CLOCK_REALTIME, so this fix works on process local primitives
only.
src/pal/src/config.h.in
src/pal/src/configure.cmake
src/pal/src/synchmgr/synchmanager.cpp
src/pal/src/synchmgr/synchmanager.hpp
src/pal/src/synchobj/mutex.cpp