Mercurial > hg > graal-compiler
diff src/os/linux/vm/os_linux.hpp @ 12211:2e6938dd68f2
6900441: PlatformEvent.park(millis) on Linux could still be affected by changes to the time-of-day clock
Summary: Associate CLOCK_MONOTONIC with the pthread_cond_t objects used for relative timed waits
Reviewed-by: dcubed, shade
author | dholmes |
---|---|
date | Mon, 16 Sep 2013 07:38:13 -0400 |
parents | 0d59407e7e09 |
children | b0133e4187d3 6c9332549827 |
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.hpp Fri Sep 13 16:56:58 2013 -0700 +++ b/src/os/linux/vm/os_linux.hpp Mon Sep 16 07:38:13 2013 -0400 @@ -221,6 +221,13 @@ static jlong fast_thread_cpu_time(clockid_t clockid); + // pthread_cond clock suppport + private: + static pthread_condattr_t _condattr[1]; + + public: + static pthread_condattr_t* condAttr() { return _condattr; } + // Stack repair handling // none present @@ -295,7 +302,7 @@ public: PlatformEvent() { int status; - status = pthread_cond_init (_cond, NULL); + status = pthread_cond_init (_cond, os::Linux::condAttr()); assert_status(status == 0, status, "cond_init"); status = pthread_mutex_init (_mutex, NULL); assert_status(status == 0, status, "mutex_init"); @@ -310,14 +317,19 @@ void park () ; void unpark () ; int TryPark () ; - int park (jlong millis) ; + int park (jlong millis) ; // relative timed-wait only void SetAssociation (Thread * a) { _Assoc = a ; } } ; class PlatformParker : public CHeapObj<mtInternal> { protected: + enum { + REL_INDEX = 0, + ABS_INDEX = 1 + }; + int _cur_index; // which cond is in use: -1, 0, 1 pthread_mutex_t _mutex [1] ; - pthread_cond_t _cond [1] ; + pthread_cond_t _cond [2] ; // one for relative times and one for abs. public: // TODO-FIXME: make dtor private ~PlatformParker() { guarantee (0, "invariant") ; } @@ -325,10 +337,13 @@ public: PlatformParker() { int status; - status = pthread_cond_init (_cond, NULL); - assert_status(status == 0, status, "cond_init"); + status = pthread_cond_init (&_cond[REL_INDEX], os::Linux::condAttr()); + assert_status(status == 0, status, "cond_init rel"); + status = pthread_cond_init (&_cond[ABS_INDEX], NULL); + assert_status(status == 0, status, "cond_init abs"); status = pthread_mutex_init (_mutex, NULL); assert_status(status == 0, status, "mutex_init"); + _cur_index = -1; // mark as unused } };