summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src/z_Linux_util.c
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2015-11-09 16:31:51 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2015-11-09 16:31:51 +0000
commit3f5dfc256204b4f4825fbfbfc7c9f985f4e78422 (patch)
tree8c13565dbd9a8fde21497ec15dfc6341b2a25073 /openmp/runtime/src/z_Linux_util.c
parentb0b83c8b0cb020425fe5cfbc892d170cec696caa (diff)
downloadbcm5719-llvm-3f5dfc256204b4f4825fbfbfc7c9f985f4e78422.tar.gz
bcm5719-llvm-3f5dfc256204b4f4825fbfbfc7c9f985f4e78422.zip
Fixes to wait-loop code
1) Add get_ptr_type() method to all wait flag types. 2) Flag in sleep_loc may change type by the time the resume is called from __kmp_null_resume_wrapper. We use get_ptr_type to obtain the real type and compare it to the casted object received. If they don't match, we know the flag has changed (already resumed and replaced by another flag). If they match, it doesn't hurt to go ahead and resume it. Differential Revision: http://reviews.llvm.org/D14458 llvm-svn: 252487
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.c')
-rw-r--r--openmp/runtime/src/z_Linux_util.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c
index dd290936756..890ec5cfaaf 100644
--- a/openmp/runtime/src/z_Linux_util.c
+++ b/openmp/runtime/src/z_Linux_util.c
@@ -1837,11 +1837,12 @@ static inline void __kmp_resume_template( int target_gtid, C *flag )
status = pthread_mutex_lock( &th->th.th_suspend_mx.m_mutex );
KMP_CHECK_SYSFAIL( "pthread_mutex_lock", status );
- if (!flag) {
+ if (!flag) { // coming from __kmp_null_resume_wrapper
flag = (C *)th->th.th_sleep_loc;
}
- if (!flag) {
+ // First, check if the flag is null or its type has changed. If so, someone else woke it up.
+ if (!flag || flag->get_type() != flag->get_ptr_type()) { // get_ptr_type simply shows what flag was cast to
KF_TRACE( 5, ( "__kmp_resume_template: T#%d exiting, thread T#%d already awake: flag(%p)\n",
gtid, target_gtid, NULL ) );
status = pthread_mutex_unlock( &th->th.th_suspend_mx.m_mutex );
OpenPOWER on IntegriCloud