Fix thread wait to be resilient to real time clock changes on Unix (dotnet/coreclr...
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)
commitf4a0ce1e0b724e185d392227d0ee4f24260a3fb4
treef5710849d50e13d78da8dcee537fd8e51e0a069f
parent7d859a03e0f11fd309ab8c67092a17879ea0a20a
Fix thread wait to be resilient to real time clock changes on Unix (dotnet/coreclr#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.

Commit migrated from https://github.com/dotnet/coreclr/commit/a5a8c6cdc6e3b732fc5a344878b165f149d99729
src/coreclr/src/pal/src/config.h.in
src/coreclr/src/pal/src/configure.cmake
src/coreclr/src/pal/src/synchmgr/synchmanager.cpp
src/coreclr/src/pal/src/synchmgr/synchmanager.hpp
src/coreclr/src/pal/src/synchobj/mutex.cpp