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.");
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.
*
#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"
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());
}
}
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;
}
/**
simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
}
-static inline double simcall_process_sleep__get__duration(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<double>(simcall->args[0]);
-}
-static inline double simcall_process_sleep__getraw__duration(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<double>(simcall->args[0]);
-}
-static inline void simcall_process_sleep__set__duration(smx_simcall_t simcall, double arg)
-{
- simgrid::simix::marshal<double>(simcall->args[0], arg);
-}
-static inline int simcall_process_sleep__get__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_process_sleep__getraw__result(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_process_sleep__set__result(smx_simcall_t simcall, int result)
-{
- simgrid::simix::marshal<int>(simcall->result, result);
-}
-
static inline simgrid::kernel::activity::ExecImpl* simcall_execution_wait__get__execution(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
/* 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);
return simcall<void, smx_actor_t>(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<int, double>(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 */
typedef enum {
SIMCALL_NONE,
SIMCALL_PROCESS_SUSPEND,
- SIMCALL_PROCESS_SLEEP,
SIMCALL_EXECUTION_WAIT,
SIMCALL_EXECUTION_WAITANY_FOR,
SIMCALL_EXECUTION_TEST,
const char* simcall_names[] = {
"SIMCALL_NONE",
"SIMCALL_PROCESS_SUSPEND",
- "SIMCALL_PROCESS_SLEEP",
"SIMCALL_EXECUTION_WAIT",
"SIMCALL_EXECUTION_WAITANY_FOR",
"SIMCALL_EXECUTION_TEST",
simcall_HANDLER_process_suspend(&simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall.args[0]));
break;
- case SIMCALL_PROCESS_SLEEP:
- simcall_HANDLER_process_sleep(&simcall, simgrid::simix::unmarshal<double>(simcall.args[0]));
- break;
-
case SIMCALL_EXECUTION_WAIT:
simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args[0]));
break;
# ./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]];