From: Martin Quinson Date: Mon, 29 Feb 2016 11:52:51 +0000 (+0100) Subject: SIMIX_process_self_{set,get}_data can retrieve the self process by themselves X-Git-Tag: v3_13~625^2~6 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a6d4c2261e41280b7a0ccd04425de8f5235216c9 SIMIX_process_self_{set,get}_data can retrieve the self process by themselves --- diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index 696da86dad..680bcd6d7d 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -51,7 +51,7 @@ public: /** The Actor that is currently running */ static Actor *current(); /** Retrieves the actor that have the given PID (or NULL if not existing) */ - static Actor *byPid(int pid); + //static Actor *byPid(int pid); not implemented /** Retrieves the name of that actor */ const char*getName(); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index c1b403c8aa..dc95bd2d7f 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -244,8 +244,8 @@ XBT_PUBLIC(void*) SIMIX_host_self_get_data(void); XBT_PUBLIC(int) SIMIX_process_count(void); XBT_PUBLIC(smx_process_t) SIMIX_process_self(void); XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void); -XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data); -XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self); +XBT_PUBLIC(void) SIMIX_process_self_set_data(void *data); +XBT_PUBLIC(void*) SIMIX_process_self_get_data(void); XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t); XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c); XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index cf719803e8..b49ab640b2 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -44,8 +44,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) { xbt_ex_t e; simdata_task_t simdata = task->simdata; - msg_process_t self = SIMIX_process_self(); - simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(self); + simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(); e_smx_state_t comp_state; msg_error_t status = MSG_OK; @@ -297,7 +296,7 @@ static XBT_INLINE msg_comm_t MSG_task_isend_internal(msg_task_t task, const char /* Prepare the task to send */ t_simdata = task->simdata; t_simdata->sender = process; - t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host; + t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host; if (t_simdata->isused != 0) { if (msg_global->debug_multiple_use){ diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 74d330d84e..cb67a3fdbf 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -154,14 +154,14 @@ msg_error_t MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, msg_error_t ret = MSG_OK; simdata_task_t t_simdata = NULL; msg_process_t process = MSG_process_self(); - simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(process); + simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(); int call_end = TRACE_msg_task_put_start(task); //must be after CHECK_HOST() /* Prepare the task to send */ t_simdata = task->simdata; t_simdata->sender = process; - t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host; + t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host; if (t_simdata->isused != 0) { if (msg_global->debug_multiple_use){ diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 5ce8704be2..7ddd2c42ed 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -34,8 +34,8 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) // get the MSG process from the SIMIX process if (smx_proc == SIMIX_process_self()) { /* avoid a SIMIX request if this function is called by the process itself */ - msg_proc = (simdata_process_t) SIMIX_process_self_get_data(smx_proc); - SIMIX_process_self_set_data(smx_proc, NULL); + msg_proc = (simdata_process_t) SIMIX_process_self_get_data(); + SIMIX_process_self_set_data(NULL); } else { msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc); simcall_process_set_data(smx_proc, NULL); @@ -294,7 +294,7 @@ msg_host_t MSG_process_get_host(msg_process_t process) { simdata_process_t simdata; if (process == NULL) { - simdata = (simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()); + simdata = (simdata_process_t) SIMIX_process_self_get_data(); } else { simdata = (simdata_process_t) simcall_process_get_data(process); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index daf355bdc3..4e7594c4f8 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -15,10 +15,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors"); /* C main function of a actor, running this->main */ -static int s4u_actor_runner(int argc, char **argv) { - - smx_process_t smx_proc = SIMIX_process_self(); - simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc); +static int s4u_actor_runner(int argc, char **argv) +{ + simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(); int res = actor->main(argc,argv); return res; } @@ -45,16 +44,14 @@ int s4u::Actor::main(int argc, char **argv) { fprintf(stderr,"Error: You should override the method main(int, char**) in Actor class %s\n",getName()); return 0; } -s4u::Actor *s4u::Actor::current() { +s4u::Actor *s4u::Actor::current() +{ smx_process_t smx_proc = SIMIX_process_self(); - simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc); + simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(); if (res == NULL) // The smx_process was not created by S4U (but by deployment?). Embed it in a S4U object res = new Actor(smx_proc); return res; } -s4u::Actor *s4u::Actor::byPid(int pid) { - return (simgrid::s4u::Actor*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid)); -} void s4u::Actor::setAutoRestart(bool autorestart) { simcall_process_auto_restart_set(p_smx_process,autorestart); diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index f61113affc..99063d9969 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -768,9 +768,9 @@ int SIMIX_process_get_PPID(smx_process_t self){ return self->ppid; } -void* SIMIX_process_self_get_data(smx_process_t self) +void* SIMIX_process_self_get_data() { - xbt_assert(self == SIMIX_process_self(), "This is not the current process"); + smx_process_t self = SIMIX_process_self(); if (!self) { return NULL; @@ -778,9 +778,9 @@ void* SIMIX_process_self_get_data(smx_process_t self) return SIMIX_process_get_data(self); } -void SIMIX_process_self_set_data(smx_process_t self, void *data) +void SIMIX_process_self_set_data(void *data) { - xbt_assert(self == SIMIX_process_self(), "This is not the current process"); + smx_process_t self = SIMIX_process_self(); SIMIX_process_set_data(self, data); } diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index e9ef952fad..de9a238613 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -214,7 +214,7 @@ int smpi_global_size(void) smpi_process_data_t smpi_process_data(void) { - simdata_process_t simdata = static_cast(SIMIX_process_self_get_data(SIMIX_process_self())); + simdata_process_t simdata = static_cast(SIMIX_process_self_get_data()); return static_cast(simdata->data); }