X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9dbeb2372ad9a123d0558132ebb6e003e10aa641..1e19722bba40db422336bb1330356a609b138ed0:/src/xbt/xbt_os_thread.c diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index c3c588fdd2..91db34bd79 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -2,7 +2,7 @@ /* Used in RL to get win/lin portability, and in SG when CONTEXT_THREAD */ /* in SG, when using CONTEXT_UCONTEXT, xbt_os_thread_stub is used instead */ -/* Copyright (c) 2007-2014. The SimGrid Team. +/* Copyright (c) 2007-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -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,16 @@ static unsigned long xbt_self_thread_key; void xbt_os_thread_mod_preinit(void) { xbt_self_thread_key = TlsAlloc(); + + xbt_os_thread_t main_thread = xbt_new0(s_xbt_os_thread_t, 1); + main_thread->name = (char *) "main"; + main_thread->start_routine = NULL; + main_thread->param = NULL; + + if (!TlsSetValue(xbt_self_thread_key, main_thread)) + THROWF(system_error, (int)GetLastError(), + "Impossible to set the SimGrid identity descriptor to the main thread (TlsSetValue() failed)"); + } void xbt_os_thread_mod_postexit(void)