From 603845ff04219895c5b7ba170940160bc8dfc619 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 6 Oct 2015 21:16:13 +0200 Subject: [PATCH 1/1] set a SimGrid identity to maestro on windows too --- src/xbt/xbt_os_thread.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index d7545b4dfb..1a085c1b72 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -111,7 +111,7 @@ void xbt_os_thread_mod_preinit(void) if ((errcode = pthread_setspecific(xbt_self_thread_key, main_thread))) THROWF(system_error, errcode, - "pthread_setspecific failed for xbt_self_thread_key"); + "Impossible to set the SimGrid identity descriptor to the main thread (pthread_setspecific failed)"); __xbt_running_ctx_fetch = _os_thread_get_running_ctx; __xbt_ex_terminate = _os_thread_ex_terminate; @@ -729,6 +729,18 @@ static unsigned long xbt_self_thread_key; void xbt_os_thread_mod_preinit(void) { xbt_self_thread_key = TlsAlloc(); + + main_thread = xbt_new(s_xbt_os_thread_t, 1); + main_thread->name = (char *) "main"; + main_thread->start_routine = NULL; + main_thread->param = NULL; + main_thread->running_ctx = xbt_new(xbt_running_ctx_t, 1); + XBT_RUNNING_CTX_INITIALIZE(main_thread->running_ctx); + + if (!TlsSetValue(xbt_self_thread_key, main_thread)) + THROWF(system_error, errcode, + "Impossible to set the SimGrid identity descriptor to the main thread (TlsSetValue() failed)"); + } void xbt_os_thread_mod_postexit(void) -- 2.20.1