From 844de0597296879c91593ae0604d5718498b81e3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 5 Jan 2019 02:11:22 +0100 Subject: [PATCH 1/1] kill the now useless xbt_os_thread_{get,set}_extra_data() --- include/xbt/xbt_os_thread.h | 5 +---- src/include/xbt/parmap.hpp | 2 +- src/kernel/context/ContextThread.cpp | 2 +- src/xbt/xbt_os_thread.c | 16 +--------------- .../parallel_log_crashtest.c | 2 +- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/include/xbt/xbt_os_thread.h b/include/xbt/xbt_os_thread.h index d555995c1a..3d0a2991fb 100644 --- a/include/xbt/xbt_os_thread.h +++ b/include/xbt/xbt_os_thread.h @@ -26,14 +26,11 @@ SG_BEGIN_DECL() /** @brief Thread data type (opaque structure) */ typedef struct xbt_os_thread_ *xbt_os_thread_t; -XBT_PUBLIC xbt_os_thread_t xbt_os_thread_create(const char* name, pvoid_f_pvoid_t start_routine, void* param, - void* data); +XBT_PUBLIC xbt_os_thread_t xbt_os_thread_create(const char* name, pvoid_f_pvoid_t start_routine, void* param); XBT_PUBLIC void xbt_os_thread_exit(int* retcode); XBT_PUBLIC xbt_os_thread_t xbt_os_thread_self(void); XBT_PUBLIC const char* xbt_os_thread_self_name(void); -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_setstacksize(int stack_size); diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index f37540bbcb..5f97049f11 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -168,7 +168,7 @@ template Parmap::Parmap(unsigned num_workers, e_xbt_parmap_mode_ unsigned int core_bind = 0; for (unsigned i = 1; i < num_workers; i++) { ThreadData* data = new ThreadData(*this, i); - this->workers[i] = xbt_os_thread_create(nullptr, worker_main, data, nullptr); + this->workers[i] = xbt_os_thread_create(nullptr, worker_main, data); xbt_os_thread_bind(this->workers[i], core_bind); if (core_bind != std::thread::hardware_concurrency() - 1) core_bind++; diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index c93e361daf..3f93201506 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -71,7 +71,7 @@ ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t c /* create and start the process */ /* NOTE: The first argument to xbt_os_thread_create used to be the process * * name, but now the name is stored at SIMIX level, so we pass a null */ - this->thread_ = xbt_os_thread_create(nullptr, ThreadContext::wrapper, this, this); + this->thread_ = xbt_os_thread_create(nullptr, ThreadContext::wrapper, this); /* wait the starting of the newly created process */ this->end_.acquire(); } diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index 4361e4148e..411aa1652f 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -48,7 +48,6 @@ typedef struct xbt_os_thread_ { char *name; void *param; pvoid_f_pvoid_t start_routine; - void *extra_data; } s_xbt_os_thread_t; static xbt_os_thread_t main_thread = NULL; @@ -82,7 +81,6 @@ void xbt_os_thread_mod_preinit(void) main_thread->name = xbt_strdup("main"); main_thread->param = NULL; main_thread->start_routine = NULL; - main_thread->extra_data = NULL; if ((errcode = pthread_setspecific(xbt_self_thread_key, main_thread))) THROWF(system_error, errcode, @@ -130,13 +128,12 @@ static void *wrapper_start_routine(void *s) return t->start_routine(t->param); } -xbt_os_thread_t xbt_os_thread_create(const char *name, pvoid_f_pvoid_t start_routine, void *param, void *extra_data) +xbt_os_thread_t xbt_os_thread_create(const char* name, pvoid_f_pvoid_t start_routine, void* param) { xbt_os_thread_t res_thread = xbt_new(s_xbt_os_thread_t, 1); res_thread->name = xbt_strdup(name); res_thread->start_routine = start_routine; res_thread->param = param; - res_thread->extra_data = extra_data; int errcode = pthread_create(&(res_thread->t), &thread_attr, wrapper_start_routine, res_thread); xbt_assert(errcode == 0, "pthread_create failed: %s", strerror(errcode)); @@ -274,14 +271,3 @@ void xbt_os_mutex_destroy(xbt_os_mutex_t mutex) xbt_assert(errcode == 0, "pthread_mutex_destroy(%p) failed: %s", mutex, strerror(errcode)); free(mutex); } - -void xbt_os_thread_set_extra_data(void *data) -{ - xbt_os_thread_self()->extra_data = data; -} - -void *xbt_os_thread_get_extra_data(void) -{ - xbt_os_thread_t thread = xbt_os_thread_self(); - return thread ? thread->extra_data : NULL; -} diff --git a/teshsuite/xbt/parallel_log_crashtest/parallel_log_crashtest.c b/teshsuite/xbt/parallel_log_crashtest/parallel_log_crashtest.c index a39cf7dd27..5d32c4e0f3 100644 --- a/teshsuite/xbt/parallel_log_crashtest/parallel_log_crashtest.c +++ b/teshsuite/xbt/parallel_log_crashtest/parallel_log_crashtest.c @@ -46,7 +46,7 @@ static int crasher() for (int i = 0; i < crasher_amount; i++) { char name[16]; snprintf(name, sizeof name, "thread %d", i); - crashers[i] = xbt_os_thread_create(name, &crasher_thread, &id[i], NULL ); + crashers[i] = xbt_os_thread_create(name, &crasher_thread, &id[i]); } /* wait for them */ -- 2.20.1