From: Martin Quinson Date: Fri, 9 Aug 2019 23:12:06 +0000 (+0200) Subject: port a blocking simcall to the modernity X-Git-Tag: v3.24~202 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f06f53287a228a869aba211842c5e46ab29b116a port a blocking simcall to the modernity --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 303093b2c6..bd2601c1e4 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -180,7 +180,9 @@ SG_BEGIN_DECL() void simcall_process_set_data(smx_actor_t process, void* data); /* Process handling */ XBT_PUBLIC void simcall_process_suspend(smx_actor_t process); -XBT_PUBLIC void simcall_process_join(smx_actor_t process, double timeout); + +XBT_ATTRIB_DEPRECATED_v327("Please use Actor::join()") XBT_PUBLIC + void simcall_process_join(smx_actor_t process, double timeout); /* Sleep control */ XBT_PUBLIC e_smx_state_t simcall_process_sleep(double duration); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 1919779135..08199ba8ab 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -600,19 +600,6 @@ const char* SIMIX_process_self_get_name() return process->get_cname(); } -void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t actor, double timeout) -{ - if (actor->finished_) { - // The joined process is already finished, just wake up the issuer process right away - simcall_process_sleep__set__result(simcall, SIMIX_DONE); - simcall->issuer->simcall_answer(); - return; - } - smx_activity_t sync = simcall->issuer->join(actor, timeout); - sync->simcalls_.push_back(simcall); - simcall->issuer->waiting_synchro = sync; -} - void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration) { if (MC_is_active() || MC_record_replay_is_active()) { diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 33d319a022..5732d13a6a 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -86,12 +86,23 @@ int Actor::get_refcount() void Actor::join() { - simcall_process_join(this->pimpl_, -1); + join(-1); } void Actor::join(double timeout) { - simcall_process_join(this->pimpl_, timeout); + auto issuer = SIMIX_process_self(); + auto target = pimpl_; + simix::simcall_blocking([issuer, target, timeout] { + if (target->finished_) { + // The joined process is already finished, just wake up the issuer right away + issuer->simcall_answer(); + } else { + smx_activity_t sync = issuer->join(target, timeout); + sync->simcalls_.push_back(&issuer->simcall); + issuer->waiting_synchro = sync; + } + }); } void Actor::set_auto_restart(bool autorestart) diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 402c6a75bf..010360d247 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -46,7 +46,7 @@ unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* void simcall_process_join(smx_actor_t process, double timeout) { - simcall_BODY_process_join(process, timeout); + SIMIX_process_self()->join(process, timeout); } /** diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index d175c0d692..5fe37d3a1f 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -28,43 +28,6 @@ static inline void simcall_process_suspend__set__process(smx_simcall_t simcall, simgrid::simix::marshal(simcall->args[0], arg); } -static inline smx_actor_t simcall_process_join__get__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_actor_t simcall_process_join__getraw__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_join__set__process(smx_simcall_t simcall, smx_actor_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline double simcall_process_join__get__timeout(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline double simcall_process_join__getraw__timeout(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_process_join__set__timeout(smx_simcall_t simcall, double arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} -static inline int simcall_process_join__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_process_join__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_process_join__set__result(smx_simcall_t simcall, int result) -{ - simgrid::simix::marshal(simcall->result, result); -} - static inline double simcall_process_sleep__get__duration(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1075,7 +1038,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f /* The prototype of all simcall handlers, automatically generated for you */ XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process); -XBT_PRIVATE void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout); XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration); XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution); XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 353945534b..8239a76945 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -46,13 +46,6 @@ inline static void simcall_BODY_process_suspend(smx_actor_t process) return simcall(SIMCALL_PROCESS_SUSPEND, process); } -inline static int simcall_BODY_process_join(smx_actor_t process, double timeout) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_process_join(&SIMIX_process_self()->simcall, process, timeout); - return simcall(SIMCALL_PROCESS_JOIN, process, timeout); -} - inline static int simcall_BODY_process_sleep(double duration) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 45a78da146..0d9f34f3cd 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -20,7 +20,6 @@ typedef enum { SIMCALL_NONE, SIMCALL_PROCESS_SUSPEND, - SIMCALL_PROCESS_JOIN, SIMCALL_PROCESS_SLEEP, SIMCALL_EXECUTION_WAIT, SIMCALL_EXECUTION_WAITANY_FOR, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index a4cc938195..981f3b90c3 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -27,7 +27,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping); const char* simcall_names[] = { "SIMCALL_NONE", "SIMCALL_PROCESS_SUSPEND", - "SIMCALL_PROCESS_JOIN", "SIMCALL_PROCESS_SLEEP", "SIMCALL_EXECUTION_WAIT", "SIMCALL_EXECUTION_WAITANY_FOR", @@ -68,10 +67,6 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) { simcall_HANDLER_process_suspend(&simcall, simgrid::simix::unmarshal(simcall.args[0])); break; - case SIMCALL_PROCESS_JOIN: - simcall_HANDLER_process_join(&simcall, simgrid::simix::unmarshal(simcall.args[0]), simgrid::simix::unmarshal(simcall.args[1])); - break; - case SIMCALL_PROCESS_SLEEP: simcall_HANDLER_process_sleep(&simcall, simgrid::simix::unmarshal(simcall.args[0])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 8dd096b280..5bbbaec503 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -36,7 +36,6 @@ # ./include/simgrid/simix.h (otherwise you will get a warning at compile time) void process_suspend(smx_actor_t process) [[block]]; -int process_join(smx_actor_t process, double timeout) [[block]]; int process_sleep(double duration) [[block]]; int execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[block]];