*/
typedef long long sg_offset_t;
+typedef unsigned long aid_t;
+
#endif
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();
*/
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) */
- static ActorPtr byPid(int pid);
+ static ActorPtr byPid(aid_t pid);
/** @brief Wait for the actor to finish.
*
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();
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 */
}
#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
return this->pimpl_->name;
}
-int Actor::pid()
+aid_t Actor::pid()
{
return this->pimpl_->pid;
}
-int Actor::ppid()
+aid_t Actor::ppid()
{
return this->pimpl_->ppid;
}
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);
// ***** 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)
return Comm::recv_async(chan, data);
}
-int pid()
+aid_t pid()
{
return SIMIX_process_self()->pid;
}
-int ppid()
+aid_t ppid()
{
return SIMIX_process_self()->ppid;
}
/**
* \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;
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 */
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 */
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.
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);
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();
}
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();
- 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);
- XBT_INFO("Resume Actor (pid=%d)", actor->pid());
+ XBT_INFO("Resume Actor (pid=%lu)", actor->pid());
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();