Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
introduce type aid_t for Actor's ID (ie, PID)
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Apr 2017 23:24:09 +0000 (01:24 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Apr 2017 23:24:09 +0000 (01:24 +0200)
include/simgrid/forward.h
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.h
src/mc/mc_base.cpp
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/smx_private.h
teshsuite/s4u/actor/actor.cpp

index 5081b05..6f81a81 100644 (file)
@@ -112,4 +112,6 @@ typedef unsigned long long sg_size_t;
  */
 typedef long long sg_offset_t;
 
  */
 typedef long long sg_offset_t;
 
+typedef unsigned long aid_t;
+
 #endif
 #endif
index c158e9d..24f7437 100644 (file)
@@ -207,10 +207,14 @@ public:
   simgrid::xbt::string name();
   /** Retrieves the host on which that actor is running */
   s4u::Host* host();
   simgrid::xbt::string name();
   /** Retrieves the host on which that actor is running */
   s4u::Host* host();
-  /** Retrieves the PID of that actor */
-  int pid();
-  /** Retrieves the PPID of that actor */
-  int ppid();
+  /** Retrieves the PID of that actor
+   *
+   * actor_id_t is an alias for unsigned long */
+  aid_t pid();
+  /** Retrieves the PPID of that actor
+   *
+   * actor_id_t is an alias for unsigned long */
+  aid_t ppid();
 
   /** Suspend an actor by suspending the task on which it was waiting for the completion. */
   void suspend();
 
   /** Suspend an actor by suspending the task on which it was waiting for the completion. */
   void suspend();
@@ -246,10 +250,10 @@ public:
    */
   void kill();
 
    */
   void kill();
 
-  static void kill(int pid);
+  static void kill(aid_t pid);
 
   /** Retrieves the actor that have the given PID (or nullptr if not existing) */
 
   /** Retrieves the actor that have the given PID (or nullptr if not existing) */
-  static ActorPtr byPid(int pid);
+  static ActorPtr byPid(aid_t pid);
 
   /** @brief Wait for the actor to finish.
    *
 
   /** @brief Wait for the actor to finish.
    *
@@ -313,11 +317,11 @@ namespace this_actor {
 
   XBT_PUBLIC(Comm&) isend(MailboxPtr chan, void* payload, double simulatedSize);
 
 
   XBT_PUBLIC(Comm&) isend(MailboxPtr chan, void* payload, double simulatedSize);
 
-  /** @brief Returns the PID of the current actor. */
-  XBT_PUBLIC(int) pid();
+  /** @brief Returns the actor ID of the current actor (same as pid). */
+  XBT_PUBLIC(aid_t) pid();
 
 
-  /** @brief Returns the PPID of the current actor. */
-  XBT_PUBLIC(int) ppid();
+  /** @brief Returns the ancestor's actor ID of the current actor (same as ppid). */
+  XBT_PUBLIC(aid_t) ppid();
 
   /** @brief Returns the name of the current actor. */
   XBT_PUBLIC(std::string) name();
 
   /** @brief Returns the name of the current actor. */
   XBT_PUBLIC(std::string) name();
index 5c3cf43..e06f54f 100644 (file)
@@ -127,7 +127,7 @@ extern int smx_context_guard_size_was_set;
 SG_BEGIN_DECL()
 
 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable();
 SG_BEGIN_DECL()
 
 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable();
-XBT_PUBLIC(smx_actor_t) SIMIX_process_from_PID(int PID);
+XBT_PUBLIC(smx_actor_t) SIMIX_process_from_PID(aid_t PID);
 XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar();
 
 /* parallelism */
 XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar();
 
 /* parallelism */
index cc57a3c..edcf150 100644 (file)
@@ -70,7 +70,7 @@ void wait_for_requests(void)
   }
 #if HAVE_MC
   xbt_dynar_reset(simix_global->actors_vector);
   }
 #if HAVE_MC
   xbt_dynar_reset(simix_global->actors_vector);
-  for (std::pair<int, smx_actor_t> kv : simix_global->process_list) {
+  for (std::pair<aid_t, smx_actor_t> kv : simix_global->process_list) {
     xbt_dynar_push_as(simix_global->actors_vector, smx_actor_t, kv.second);
   }
 #endif
     xbt_dynar_push_as(simix_global->actors_vector, smx_actor_t, kv.second);
   }
 #endif
index 96ec075..bbed1a8 100644 (file)
@@ -77,12 +77,12 @@ simgrid::xbt::string Actor::name()
   return this->pimpl_->name;
 }
 
   return this->pimpl_->name;
 }
 
-int Actor::pid()
+aid_t Actor::pid()
 {
   return this->pimpl_->pid;
 }
 
 {
   return this->pimpl_->pid;
 }
 
-int Actor::ppid()
+aid_t Actor::ppid()
 {
   return this->pimpl_->ppid;
 }
 {
   return this->pimpl_->ppid;
 }
@@ -111,7 +111,8 @@ double Actor::killTime()
   return simcall_process_get_kill_time(pimpl_);
 }
 
   return simcall_process_get_kill_time(pimpl_);
 }
 
-void Actor::kill(int pid) {
+void Actor::kill(aid_t pid)
+{
   smx_actor_t process = SIMIX_process_from_PID(pid);
   if(process != nullptr) {
     simcall_process_kill(process);
   smx_actor_t process = SIMIX_process_from_PID(pid);
   if(process != nullptr) {
     simcall_process_kill(process);
@@ -132,7 +133,7 @@ void Actor::kill() {
 
 // ***** Static functions *****
 
 
 // ***** Static functions *****
 
-ActorPtr Actor::byPid(int pid)
+ActorPtr Actor::byPid(aid_t pid)
 {
   smx_actor_t process = SIMIX_process_from_PID(pid);
   if (process != nullptr)
 {
   smx_actor_t process = SIMIX_process_from_PID(pid);
   if (process != nullptr)
@@ -209,12 +210,12 @@ Comm& irecv(MailboxPtr chan, void** data)
   return Comm::recv_async(chan, data);
 }
 
   return Comm::recv_async(chan, data);
 }
 
-int pid()
+aid_t pid()
 {
   return SIMIX_process_self()->pid;
 }
 
 {
   return SIMIX_process_self()->pid;
 }
 
-int ppid()
+aid_t ppid()
 {
   return SIMIX_process_self()->ppid;
 }
 {
   return SIMIX_process_self()->ppid;
 }
index 43944d0..606bece 100644 (file)
@@ -866,7 +866,7 @@ xbt_dynar_t SIMIX_process_get_runnable()
 /**
  * \brief Returns the process from PID.
  */
 /**
  * \brief Returns the process from PID.
  */
-smx_actor_t SIMIX_process_from_PID(int PID)
+smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
   if (simix_global->process_list.find(PID) == simix_global->process_list.end())
     return nullptr;
 {
   if (simix_global->process_list.find(PID) == simix_global->process_list.end())
     return nullptr;
index 9e4930d..906c4cd 100644 (file)
@@ -40,8 +40,8 @@ public:
   s_xbt_swag_hookup_t host_proc_hookup = { nullptr, nullptr }; /* smx_host->process_lis */
   s_xbt_swag_hookup_t destroy_hookup   = { nullptr, nullptr }; /* simix_global->process_to_destroy */
 
   s_xbt_swag_hookup_t host_proc_hookup = { nullptr, nullptr }; /* smx_host->process_lis */
   s_xbt_swag_hookup_t destroy_hookup   = { nullptr, nullptr }; /* simix_global->process_to_destroy */
 
-  unsigned long pid  = 0;
-  unsigned long ppid = -1;
+  aid_t pid  = 0;
+  aid_t ppid = -1;
   simgrid::xbt::string name;
   const char* cname() { return name.c_str(); }
   s4u::Host* host       = nullptr; /* the host on which the process is running */
   simgrid::xbt::string name;
   const char* cname() { return name.c_str(); }
   s4u::Host* host       = nullptr; /* the host on which the process is running */
@@ -56,7 +56,7 @@ public:
 
   sg_host_t new_host            = nullptr; /* if not null, the host on which the process must migrate to */
   smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
 
   sg_host_t new_host            = nullptr; /* if not null, the host on which the process must migrate to */
   smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
-  std::list<smx_activity_t> comms               ;           /* the current non-blocking communication synchros */
+  std::list<smx_activity_t> comms;          /* the current non-blocking communication synchros */
   xbt_dict_t properties         = nullptr;
   s_smx_simcall_t simcall;
   void *data          = nullptr; /* kept for compatibility, it should be replaced with moddata */
   xbt_dict_t properties         = nullptr;
   s_smx_simcall_t simcall;
   void *data          = nullptr; /* kept for compatibility, it should be replaced with moddata */
index 6999488..9ec2107 100644 (file)
@@ -21,7 +21,7 @@ public:
   smx_context_factory_t context_factory = nullptr;
   xbt_dynar_t process_to_run = nullptr;
   xbt_dynar_t process_that_ran = nullptr;
   smx_context_factory_t context_factory = nullptr;
   xbt_dynar_t process_to_run = nullptr;
   xbt_dynar_t process_that_ran = nullptr;
-  std::map<int, smx_actor_t> process_list;
+  std::map<aid_t, smx_actor_t> process_list;
 #if HAVE_MC
   /* MCer cannot read the std::map above in the remote process, so we copy the info it needs in a dynar.
    * FIXME: This is supposed to be a temporary hack.
 #if HAVE_MC
   /* MCer cannot read the std::map above in the remote process, so we copy the info it needs in a dynar.
    * FIXME: This is supposed to be a temporary hack.
index d7a8628..3be9b12 100644 (file)
@@ -10,7 +10,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
 static void worker()
 {
   simgrid::s4u::this_actor::sleep_for(.5);
 static void worker()
 {
   simgrid::s4u::this_actor::sleep_for(.5);
-  XBT_INFO("Worker started (PID:%d, PPID:%d)", simgrid::s4u::this_actor::pid(), simgrid::s4u::this_actor::ppid());
+  XBT_INFO("Worker started (PID:%lu, PPID:%lu)", simgrid::s4u::this_actor::pid(), simgrid::s4u::this_actor::ppid());
   while (1) {
     XBT_INFO("Plop i am %ssuspended", simgrid::s4u::this_actor::isSuspended() ? "" : "not ");
     simgrid::s4u::this_actor::sleep_for(1);
   while (1) {
     XBT_INFO("Plop i am %ssuspended", simgrid::s4u::this_actor::isSuspended() ? "" : "not ");
     simgrid::s4u::this_actor::sleep_for(1);
@@ -25,7 +25,7 @@ static void master()
   simgrid::s4u::this_actor::host()->actorList(actor_list);
 
   for (auto actor : *actor_list) {
   simgrid::s4u::this_actor::host()->actorList(actor_list);
 
   for (auto actor : *actor_list) {
-    XBT_INFO("Actor (pid=%d, ppid=%d, name=%s)", actor->pid(), actor->ppid(), actor->name().c_str());
+    XBT_INFO("Actor (pid=%lu, ppid=%lu, name=%s)", actor->pid(), actor->ppid(), actor->name().c_str());
     if (simgrid::s4u::this_actor::pid() != actor->pid())
       actor->kill();
   }
     if (simgrid::s4u::this_actor::pid() != actor->pid())
       actor->kill();
   }
@@ -34,16 +34,16 @@ static void master()
       simgrid::s4u::Actor::createActor("worker from master", simgrid::s4u::this_actor::host(), worker);
   simgrid::s4u::this_actor::sleep_for(2);
 
       simgrid::s4u::Actor::createActor("worker from master", simgrid::s4u::this_actor::host(), worker);
   simgrid::s4u::this_actor::sleep_for(2);
 
-  XBT_INFO("Suspend Actor (pid=%d)", actor->pid());
+  XBT_INFO("Suspend Actor (pid=%lu)", actor->pid());
   actor->suspend();
 
   actor->suspend();
 
-  XBT_INFO("Actor (pid=%d) is %ssuspended", actor->pid(), actor->isSuspended() ? "" : "not ");
+  XBT_INFO("Actor (pid=%lu) is %ssuspended", actor->pid(), actor->isSuspended() ? "" : "not ");
   simgrid::s4u::this_actor::sleep_for(2);
 
   simgrid::s4u::this_actor::sleep_for(2);
 
-  XBT_INFO("Resume Actor (pid=%d)", actor->pid());
+  XBT_INFO("Resume Actor (pid=%lu)", actor->pid());
   actor->resume();
 
   actor->resume();
 
-  XBT_INFO("Actor (pid=%d) is %ssuspended", actor->pid(), actor->isSuspended() ? "" : "not ");
+  XBT_INFO("Actor (pid=%lu) is %ssuspended", actor->pid(), actor->isSuspended() ? "" : "not ");
   simgrid::s4u::this_actor::sleep_for(2);
   actor->kill();
 
   simgrid::s4u::this_actor::sleep_for(2);
   actor->kill();