X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cd077da6be23eb5a0682927d41d8fb104b846aea..36afc6b22dc5db467c2286c7c352cb80708227ce:/src/kernel/context/ContextBoost.cpp diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index a9422e0d0c..91843867f1 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -1,12 +1,10 @@ -/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2015-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "ContextBoost.hpp" - -#include -#include +#include "src/simix/smx_private.hpp" #if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT #include @@ -202,7 +200,7 @@ void SerialBoostContext::run_all() #if HAVE_THREAD_CONTEXTS simgrid::xbt::Parmap* ParallelBoostContext::parmap_; -uintptr_t ParallelBoostContext::threads_working_; +std::atomic ParallelBoostContext::threads_working_; xbt_os_thread_key_t ParallelBoostContext::worker_id_key_; std::vector ParallelBoostContext::workers_context_; @@ -254,7 +252,7 @@ void ParallelBoostContext::suspend() void ParallelBoostContext::resume() { - uintptr_t worker_id = __sync_fetch_and_add(&threads_working_, 1); + uintptr_t worker_id = threads_working_.fetch_add(1, std::memory_order_relaxed); xbt_os_thread_set_specific(worker_id_key_, reinterpret_cast(worker_id)); ParallelBoostContext* worker_context = static_cast(SIMIX_context_self());