From: Frederic Suter Date: Mon, 18 Feb 2019 19:49:42 +0000 (+0100) Subject: SIMIX_synchro_wait becomes RawImpl::start X-Git-Tag: v3_22~311 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/efe776a7f971fa0f6641baa5c835364604b600c8 SIMIX_synchro_wait becomes RawImpl::start --- diff --git a/src/kernel/activity/ConditionVariableImpl.cpp b/src/kernel/activity/ConditionVariableImpl.cpp index 144373c740..fa4b9cf03d 100644 --- a/src/kernel/activity/ConditionVariableImpl.cpp +++ b/src/kernel/activity/ConditionVariableImpl.cpp @@ -17,7 +17,7 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, smx_simcall_t simcall) { XBT_IN("(%p, %p, %f, %p,%p)", cond, mutex, timeout, issuer, simcall); - smx_activity_t synchro = nullptr; + simgrid::kernel::activity::RawImplPtr synchro = nullptr; XBT_DEBUG("Wait condition %p", cond); @@ -28,7 +28,8 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, mutex->unlock(issuer); } - synchro = SIMIX_synchro_wait(issuer->get_host(), timeout); + synchro = simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl()) + ->start(issuer->get_host(), timeout); synchro->simcalls_.push_front(simcall); issuer->waiting_synchro = synchro; cond->sleeping.push_back(*simcall->issuer); diff --git a/src/kernel/activity/MutexImpl.cpp b/src/kernel/activity/MutexImpl.cpp index 538e418f37..67b5dc8e04 100644 --- a/src/kernel/activity/MutexImpl.cpp +++ b/src/kernel/activity/MutexImpl.cpp @@ -29,12 +29,12 @@ void MutexImpl::lock(smx_actor_t issuer) { XBT_IN("(%p; %p)", this, issuer); /* FIXME: check where to validate the arguments */ - smx_activity_t synchro = nullptr; + RawImplPtr synchro = nullptr; if (this->locked) { /* FIXME: check if the host is active ? */ /* Somebody using the mutex, use a synchronization to get host failures */ - synchro = SIMIX_synchro_wait(issuer->get_host(), -1); + synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), -1); synchro->simcalls_.push_back(&issuer->simcall); issuer->waiting_synchro = synchro; this->sleeping.push_back(*issuer); diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index 9d47f0bce5..cedb307903 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/activity/SemaphoreImpl.hpp" +#include "src/kernel/activity/SynchroRaw.hpp" #include "src/simix/smx_synchro_private.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_semaphore, simix_synchro, "Semaphore kernel-space implementation"); @@ -14,11 +15,11 @@ namespace activity { void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout) { - smx_activity_t synchro = nullptr; + RawImplPtr synchro = nullptr; XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout); if (value_ <= 0) { - synchro = SIMIX_synchro_wait(issuer->get_host(), timeout); + synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), timeout); synchro->simcalls_.push_front(&issuer->simcall); issuer->waiting_synchro = synchro; sleeping_.push_back(*issuer); diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index 9326bd2239..5b3efd5c5a 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -7,17 +7,28 @@ #include "simgrid/kernel/resource/Action.hpp" #include "src/kernel/context/Context.hpp" #include "src/simix/smx_synchro_private.hpp" +#include "src/surf/cpu_interface.hpp" #include "src/surf/surf_interface.hpp" +#include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro); + namespace simgrid { namespace kernel { namespace activity { +RawImpl* RawImpl::start(s4u::Host* host, double timeout) +{ + surf_action_ = host->pimpl_cpu->sleep(timeout); + surf_action_->set_data(this); + return this; +} + RawImpl::~RawImpl() { surf_action_->unref(); } + void RawImpl::suspend() { /* The suspension of raw synchros is delayed to when the process is rescheduled. */ diff --git a/src/kernel/activity/SynchroRaw.hpp b/src/kernel/activity/SynchroRaw.hpp index c96dd4a6fd..a8289758d1 100644 --- a/src/kernel/activity/SynchroRaw.hpp +++ b/src/kernel/activity/SynchroRaw.hpp @@ -17,6 +17,7 @@ namespace activity { class XBT_PUBLIC RawImpl : public ActivityImpl { public: ~RawImpl() override; + RawImpl* start(s4u::Host* host, double timeout); void suspend() override; void resume() override; void post() override; diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index 561d1e8a63..2ca5dc3065 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -70,7 +70,7 @@ public: std::vector on_exit; /* list of functions executed when the process dies */ std::function code; - smx_timer_t kill_timer = nullptr; + simix::Timer* kill_timer = nullptr; private: /* Refcounting */ diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index 0cd3b01a9d..07a4ab63b7 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -6,27 +6,13 @@ #include "src/kernel/activity/ConditionVariableImpl.hpp" #include "src/kernel/activity/MutexImpl.hpp" #include "src/kernel/activity/SemaphoreImpl.hpp" -#include "src/kernel/activity/SynchroRaw.hpp" #include "src/kernel/context/Context.hpp" #include "src/simix/smx_synchro_private.hpp" -#include "src/surf/cpu_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix, "SIMIX Synchronization (mutex, semaphores and conditions)"); /***************************** Raw synchronization *********************************/ -smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout) -{ - XBT_IN("(%p, %f)",smx_host,timeout); - - simgrid::kernel::activity::RawImplPtr sync = - simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl()); - sync->surf_action_ = smx_host->pimpl_cpu->sleep(timeout); - sync->surf_action_->set_data(sync.get()); - XBT_OUT(); - return sync; -} - void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall) { XBT_IN("(%p, %p)",process,simcall); diff --git a/src/simix/smx_synchro_private.hpp b/src/simix/smx_synchro_private.hpp index 51482fffff..97fc9b8484 100644 --- a/src/simix/smx_synchro_private.hpp +++ b/src/simix/smx_synchro_private.hpp @@ -8,8 +8,6 @@ #include "src/simix/ActorImpl.hpp" -smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout); - XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall); #endif