From: Martin Quinson Date: Sat, 10 Aug 2019 13:41:08 +0000 (+0200) Subject: convert simcall_process_sleep to modernity X-Git-Tag: v3.24~200 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1b7cdf70314fdcd605fe4dcf54e4fe0b76c1be3a convert simcall_process_sleep to modernity --- diff --git a/src/kernel/activity/SleepImpl.cpp b/src/kernel/activity/SleepImpl.cpp index 90d88e94dc..4cf48083f7 100644 --- a/src/kernel/activity/SleepImpl.cpp +++ b/src/kernel/activity/SleepImpl.cpp @@ -57,7 +57,6 @@ void SleepImpl::finish() smx_simcall_t simcall = simcalls_.front(); simcalls_.pop_front(); - simcall_process_sleep__set__result(simcall, state_); simcall->issuer->waiting_synchro = nullptr; if (simcall->issuer->is_suspended()) { XBT_DEBUG("Wait! This process is suspended and can't wake up now."); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 08199ba8ab..d8214a7a19 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_sleep(smx_simcall_t simcall, double duration) -{ - if (MC_is_active() || MC_record_replay_is_active()) { - MC_process_clock_add(simcall->issuer, duration); - simcall_process_sleep__set__result(simcall, SIMIX_DONE); - simcall->issuer->simcall_answer(); - return; - } - smx_activity_t sync = simcall->issuer->sleep(duration); - sync->simcalls_.push_back(simcall); - simcall->issuer->waiting_synchro = sync; -} - /** * @brief Calling this function makes the process to yield. * diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 5732d13a6a..e351ed7592 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -5,11 +5,14 @@ #include "simgrid/Exception.hpp" #include "simgrid/actor.h" +#include "simgrid/modelchecker.h" #include "simgrid/s4u/Actor.hpp" #include "simgrid/s4u/Exec.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/VirtualMachine.hpp" +#include "src/include/mc/mc.h" #include "src/kernel/activity/ExecImpl.hpp" +#include "src/mc/mc_replay.hpp" #include "src/simix/smx_private.hpp" #include "src/surf/HostImpl.hpp" @@ -290,13 +293,25 @@ bool is_maestro() void sleep_for(double duration) { + xbt_assert(std::isfinite(duration), "duration is not finite!"); + if (duration > 0) { - kernel::actor::ActorImpl* actor = SIMIX_process_self(); - Actor::on_sleep(*actor->ciface()); + kernel::actor::ActorImpl* issuer = SIMIX_process_self(); + Actor::on_sleep(*issuer->ciface()); + + simix::simcall_blocking([issuer, duration]() { + if (MC_is_active() || MC_record_replay_is_active()) { + MC_process_clock_add(issuer, duration); + issuer->simcall_answer(); + return; + } + smx_activity_t sync = issuer->sleep(duration); + sync->simcalls_.push_back(&issuer->simcall); + issuer->waiting_synchro = sync; - simcall_process_sleep(duration); + }); - Actor::on_wake_up(*actor->ciface()); + Actor::on_wake_up(*issuer->ciface()); } } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 010360d247..e2a4e63cd6 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -58,22 +58,10 @@ void simcall_process_suspend(smx_actor_t process) simcall_BODY_process_suspend(process); } -/** - * @ingroup simix_process_management - * @brief Creates a new sleep SIMIX synchro. - * - * This function creates a SURF action and allocates the data necessary - * to create the SIMIX synchro. It can raise a HostFailureException if the - * host crashed. The default SIMIX name of the synchro is "sleep". - * - * @param duration Time duration of the sleep. - * @return A result telling whether the sleep was successful - */ e_smx_state_t simcall_process_sleep(double duration) { - /* checking for infinite values */ - xbt_assert(std::isfinite(duration), "duration is not finite!"); - return (e_smx_state_t) simcall_BODY_process_sleep(duration); + SIMIX_process_self()->sleep(duration); + return SIMIX_DONE; } /** diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 5fe37d3a1f..ea7db0f99a 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -28,31 +28,6 @@ static inline void simcall_process_suspend__set__process(smx_simcall_t simcall, simgrid::simix::marshal(simcall->args[0], arg); } -static inline double simcall_process_sleep__get__duration(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline double simcall_process_sleep__getraw__duration(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_sleep__set__duration(smx_simcall_t simcall, double arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline int simcall_process_sleep__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_process_sleep__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_process_sleep__set__result(smx_simcall_t simcall, int result) -{ - simgrid::simix::marshal(simcall->result, result); -} - static inline simgrid::kernel::activity::ExecImpl* simcall_execution_wait__get__execution(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1038,7 +1013,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_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); XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 8239a76945..e5d44ad56b 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_sleep(double duration) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_process_sleep(&SIMIX_process_self()->simcall, duration); - return simcall(SIMCALL_PROCESS_SLEEP, duration); -} - inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution) { 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 0d9f34f3cd..8a477ff714 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_SLEEP, SIMCALL_EXECUTION_WAIT, SIMCALL_EXECUTION_WAITANY_FOR, SIMCALL_EXECUTION_TEST, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 981f3b90c3..6b68380117 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_SLEEP", "SIMCALL_EXECUTION_WAIT", "SIMCALL_EXECUTION_WAITANY_FOR", "SIMCALL_EXECUTION_TEST", @@ -67,10 +66,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_SLEEP: - simcall_HANDLER_process_sleep(&simcall, simgrid::simix::unmarshal(simcall.args[0])); - break; - case SIMCALL_EXECUTION_WAIT: simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal(simcall.args[0])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 5bbbaec503..6d264cb298 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_sleep(double duration) [[block]]; int execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[block]]; int execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) [[block]];