X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/347996b4a10c4e8579080692afa60e0afb88b60a..f5acac9da28f84a6625be7afaa01fc4ec6c643e7:/src/simix/ThreadContext.cpp diff --git a/src/simix/ThreadContext.cpp b/src/simix/ThreadContext.cpp index c84dc52918..722ff30f60 100644 --- a/src/simix/ThreadContext.cpp +++ b/src/simix/ThreadContext.cpp @@ -9,7 +9,7 @@ #include "xbt/function_types.h" #include "smx_private.h" -#include "src/portable.h" /* loads context system definitions */ +#include "src/internal_config.h" /* loads context system definitions */ #include "xbt/swag.h" #include "xbt/xbt_os_thread.h" #include "src/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */ @@ -98,11 +98,9 @@ ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t cleanup, smx_process_t process, bool maestro) : AttachContext(std::move(code), cleanup, process) { - // We do not need the semaphores when maestro is in main: - // if (!(maestro && !code)) { - this->begin_ = xbt_os_sem_init(0); - this->end_ = xbt_os_sem_init(0); - // } + // We do not need the semaphores when maestro is in main, but we create them anyway for simplicity wrt the case where maestro is externalized + this->begin_ = xbt_os_sem_init(0); + this->end_ = xbt_os_sem_init(0); /* If the user provided a function for the process then use it */ if (has_code()) { @@ -130,15 +128,12 @@ ThreadContext::ThreadContext(std::function code, ThreadContext::~ThreadContext() { - /* check if this is the context of maestro (it doesn't have a real thread) */ - if (this->thread_) { - /* wait about the thread terminason */ + if (this->thread_) /* If there is a thread (maestro don't have any), wait for its termination */ xbt_os_thread_join(this->thread_, nullptr); - /* destroy the synchronisation objects */ - xbt_os_sem_destroy(this->begin_); - xbt_os_sem_destroy(this->end_); - } + /* destroy the synchronization objects */ + xbt_os_sem_destroy(this->begin_); + xbt_os_sem_destroy(this->end_); } void *ThreadContext::wrapper(void *param)