From cf0ebedfe4a6fd8a14784135e912725b7e027d6f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 18 Jul 2018 22:28:45 +0200 Subject: [PATCH 1/1] get rid of xbt_os_thread_yield() using C++11 --- ChangeLog | 1 + include/xbt/xbt_os_thread.h | 1 - src/include/xbt/parmap.hpp | 5 +++-- src/xbt/xbt_os_thread.c | 6 ------ 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f53f1afb98..38b1e5e4eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Tracing: XBT: - Remove xbt_os_thread_specific features - Remove portability wrapper to condition variables + - Remove xbt_os_thread_yield() Fixed bugs: - #264: Add ptask L07 resource tracing diff --git a/include/xbt/xbt_os_thread.h b/include/xbt/xbt_os_thread.h index 5c4f2ae5a1..e1591c7f97 100644 --- a/include/xbt/xbt_os_thread.h +++ b/include/xbt/xbt_os_thread.h @@ -38,7 +38,6 @@ XBT_PUBLIC void xbt_os_thread_set_extra_data(void* data); XBT_PUBLIC void* xbt_os_thread_get_extra_data(void); /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */ XBT_PUBLIC void xbt_os_thread_join(xbt_os_thread_t thread, void** thread_return); -XBT_PUBLIC void xbt_os_thread_yield(void); XBT_PUBLIC void xbt_os_thread_setstacksize(int stack_size); XBT_PUBLIC void xbt_os_thread_setguardsize(int guard_size); XBT_PUBLIC int xbt_os_thread_bind(xbt_os_thread_t thread, int core); diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index b5b72de11e..b8fbed6b5d 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #if HAVE_FUTEX_H #include @@ -411,7 +412,7 @@ template void Parmap::BusyWaitSynchro::master_signal() template void Parmap::BusyWaitSynchro::master_wait() { while (__atomic_load_n(&this->parmap.thread_counter, __ATOMIC_SEQ_CST) < this->parmap.num_workers) { - xbt_os_thread_yield(); + std::this_thread::yield(); } } @@ -424,7 +425,7 @@ template void Parmap::BusyWaitSynchro::worker_wait(unsigned roun { /* wait for more work */ while (__atomic_load_n(&this->parmap.work_round, __ATOMIC_SEQ_CST) != round) { - xbt_os_thread_yield(); + std::this_thread::yield(); } } diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index fc6b5746f8..79242cdf5a 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -246,12 +246,6 @@ xbt_os_thread_t xbt_os_thread_self(void ) return pthread_getspecific(xbt_self_thread_key); } -#include -void xbt_os_thread_yield(void) -{ - sched_yield(); -} - /****** mutex related functions ******/ typedef struct xbt_os_mutex_ { pthread_mutex_t m; -- 2.20.1