Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SIMIX_synchro_wait becomes RawImpl::start
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 18 Feb 2019 19:49:42 +0000 (20:49 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 18 Feb 2019 19:55:48 +0000 (20:55 +0100)
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/MutexImpl.cpp
src/kernel/activity/SemaphoreImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/activity/SynchroRaw.hpp
src/simix/ActorImpl.hpp
src/simix/smx_synchro.cpp
src/simix/smx_synchro_private.hpp

index 144373c..fa4b9cf 100644 (file)
@@ -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_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);
 
 
   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);
   }
 
     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);
   synchro->simcalls_.push_front(simcall);
   issuer->waiting_synchro = synchro;
   cond->sleeping.push_back(*simcall->issuer);
index 538e418..67b5dc8 100644 (file)
@@ -29,12 +29,12 @@ void MutexImpl::lock(smx_actor_t issuer)
 {
   XBT_IN("(%p; %p)", this, issuer);
   /* FIXME: check where to validate the arguments */
 {
   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 */
 
   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);
     synchro->simcalls_.push_back(&issuer->simcall);
     issuer->waiting_synchro = synchro;
     this->sleeping.push_back(*issuer);
index 9d47f0b..cedb307 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/activity/SemaphoreImpl.hpp"
  * 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");
 #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)
 {
 
 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) {
 
   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);
     synchro->simcalls_.push_front(&issuer->simcall);
     issuer->waiting_synchro = synchro;
     sleeping_.push_back(*issuer);
index 9326bd2..5b3efd5 100644 (file)
@@ -7,17 +7,28 @@
 #include "simgrid/kernel/resource/Action.hpp"
 #include "src/kernel/context/Context.hpp"
 #include "src/simix/smx_synchro_private.hpp"
 #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 "src/surf/surf_interface.hpp"
+#include <simgrid/s4u/Host.hpp>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
+
 namespace simgrid {
 namespace kernel {
 namespace activity {
 
 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();
 }
 RawImpl::~RawImpl()
 {
   surf_action_->unref();
 }
+
 void RawImpl::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
 void RawImpl::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
index c96dd4a..a828975 100644 (file)
@@ -17,6 +17,7 @@ namespace activity {
 class XBT_PUBLIC RawImpl : public ActivityImpl {
 public:
   ~RawImpl() override;
 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;
   void suspend() override;
   void resume() override;
   void post() override;
index 561d1e8..2ca5dc3 100644 (file)
@@ -70,7 +70,7 @@ public:
   std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
 
   std::function<void()> code;
   std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
 
   std::function<void()> code;
-  smx_timer_t kill_timer = nullptr;
+  simix::Timer* kill_timer = nullptr;
 
 private:
   /* Refcounting */
 
 private:
   /* Refcounting */
index 0cd3b01..07a4ab6 100644 (file)
@@ -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/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/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 *********************************/
 
 
 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);
 void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall)
 {
   XBT_IN("(%p, %p)",process,simcall);
index 51482ff..97fc9b8 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "src/simix/ActorImpl.hpp"
 
 
 #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
 XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall);
 
 #endif