--- a/src/hotspot/os/solaris/os_solaris.cpp Thu May 28 11:43:31 2020 +++ b/src/hotspot/os/solaris/os_solaris.cpp Thu May 28 13:53:16 2020 @@ -2748,52 +2748,35 @@ bool os::Solaris::_synchronization_initialized; void os::Solaris::synchronization_init() { - if (UseLWPSynchronization) { - os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_lock"))); - os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_trylock"))); - os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_unlock"))); - os::Solaris::set_mutex_init(lwp_mutex_init); - os::Solaris::set_mutex_destroy(lwp_mutex_destroy); - os::Solaris::set_mutex_scope(USYNC_THREAD); + os::Solaris::set_mutex_scope(USYNC_THREAD); + os::Solaris::set_cond_scope(USYNC_THREAD); - os::Solaris::set_cond_timedwait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP_timestruc_tP, resolve_symbol("_lwp_cond_timedwait"))); - os::Solaris::set_cond_wait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP, resolve_symbol("_lwp_cond_wait"))); - os::Solaris::set_cond_signal(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("_lwp_cond_signal"))); - os::Solaris::set_cond_broadcast(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("_lwp_cond_broadcast"))); - os::Solaris::set_cond_init(lwp_cond_init); - os::Solaris::set_cond_destroy(lwp_cond_destroy); - os::Solaris::set_cond_scope(USYNC_THREAD); + if (UsePthreads) { + os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_lock"))); + os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_trylock"))); + os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_unlock"))); + os::Solaris::set_mutex_init(pthread_mutex_default_init); + os::Solaris::set_mutex_destroy(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_destroy"))); + + os::Solaris::set_cond_timedwait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP_timestruc_tP, resolve_symbol("pthread_cond_timedwait"))); + os::Solaris::set_cond_wait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP, resolve_symbol("pthread_cond_wait"))); + os::Solaris::set_cond_signal(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_signal"))); + os::Solaris::set_cond_broadcast(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_broadcast"))); + os::Solaris::set_cond_init(pthread_cond_default_init); + os::Solaris::set_cond_destroy(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_destroy"))); } else { - os::Solaris::set_mutex_scope(USYNC_THREAD); - os::Solaris::set_cond_scope(USYNC_THREAD); + os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_lock"))); + os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_trylock"))); + os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_unlock"))); + os::Solaris::set_mutex_init(::mutex_init); + os::Solaris::set_mutex_destroy(::mutex_destroy); - if (UsePthreads) { - os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_lock"))); - os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_trylock"))); - os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_unlock"))); - os::Solaris::set_mutex_init(pthread_mutex_default_init); - os::Solaris::set_mutex_destroy(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_destroy"))); - - os::Solaris::set_cond_timedwait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP_timestruc_tP, resolve_symbol("pthread_cond_timedwait"))); - os::Solaris::set_cond_wait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP, resolve_symbol("pthread_cond_wait"))); - os::Solaris::set_cond_signal(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_signal"))); - os::Solaris::set_cond_broadcast(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_broadcast"))); - os::Solaris::set_cond_init(pthread_cond_default_init); - os::Solaris::set_cond_destroy(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("pthread_cond_destroy"))); - } else { - os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_lock"))); - os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_trylock"))); - os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("mutex_unlock"))); - os::Solaris::set_mutex_init(::mutex_init); - os::Solaris::set_mutex_destroy(::mutex_destroy); - - os::Solaris::set_cond_timedwait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP_timestruc_tP, resolve_symbol("cond_timedwait"))); - os::Solaris::set_cond_wait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP, resolve_symbol("cond_wait"))); - os::Solaris::set_cond_signal(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("cond_signal"))); - os::Solaris::set_cond_broadcast(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("cond_broadcast"))); - os::Solaris::set_cond_init(::cond_init); + os::Solaris::set_cond_timedwait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP_timestruc_tP, resolve_symbol("cond_timedwait"))); + os::Solaris::set_cond_wait(CAST_TO_FN_PTR(int_fnP_cond_tP_mutex_tP, resolve_symbol("cond_wait"))); + os::Solaris::set_cond_signal(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("cond_signal"))); + os::Solaris::set_cond_broadcast(CAST_TO_FN_PTR(int_fnP_cond_tP, resolve_symbol("cond_broadcast"))); + os::Solaris::set_cond_init(::cond_init); os::Solaris::set_cond_destroy(::cond_destroy); - } } _synchronization_initialized = true; } @@ -3535,9 +3518,6 @@ // 3. Tx resumes from park -// value determined through experimentation -#define ROUNDINGFIX 11 - // utility to compute the abstime argument to timedwait. // TODO-FIXME: switch from compute_abstime() to unpackTime(). @@ -3551,24 +3531,8 @@ jlong seconds = millis / 1000; jlong max_wait_period; - if (UseLWPSynchronization) { - // forward port of fix for 4275818 (not sleeping long enough) - // There was a bug in Solaris 6, 7 and pre-patch 5 of 8 where - // _lwp_cond_timedwait() used a round_down algorithm rather - // than a round_up. For millis less than our roundfactor - // it rounded down to 0 which doesn't meet the spec. - // For millis > roundfactor we may return a bit sooner, but - // since we can not accurately identify the patch level and - // this has already been fixed in Solaris 9 and 8 we will - // leave it alone rather than always rounding down. + max_wait_period = 50000000; - if (millis > 0 && millis < ROUNDINGFIX) millis = ROUNDINGFIX; - // It appears that when we go directly through Solaris _lwp_cond_timedwait() - // the acceptable max time threshold is smaller than for libthread on 2.5.1 and 2.6 - max_wait_period = 21000000; - } else { - max_wait_period = 50000000; - } millis %= 1000; if (seconds > max_wait_period) { // see man cond_timedwait(3T) seconds = max_wait_period;