/**************************** Process simcalls ********************************/
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_ATTRIB_DEPRECATED_v327("Please use Actor::suspend()") XBT_PUBLIC void simcall_process_suspend(smx_actor_t process);
XBT_ATTRIB_DEPRECATED_v327("Please use Actor::join()") XBT_PUBLIC
void simcall_process_join(smx_actor_t process, double timeout);
if (simcall->issuer->is_suspended()) {
XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
simcall->issuer->suspended_ = false;
- simcall_HANDLER_process_suspend(simcall, simcall->issuer);
+ simcall->issuer->suspend(simcall->issuer);
} else {
simcall->issuer->simcall_answer();
}
return actor->ciface();
}
-activity::ActivityImplPtr ActorImpl::suspend(ActorImpl* issuer)
+void ActorImpl::suspend(ActorImpl* issuer)
{
if (suspended_) {
XBT_DEBUG("Actor '%s' is already suspended", get_cname());
- return nullptr;
+ return;
}
suspended_ = true;
- /* If we are suspending another actor that is waiting on a sync, suspend its synchronization. */
- if (this != issuer) {
- if (waiting_synchro)
- waiting_synchro->suspend();
- /* If the other actor is not waiting, its suspension is delayed to when the actor is rescheduled. */
-
- return nullptr;
- } else {
+ /* If the suspended actor is waiting on a sync, suspend its synchronization. */
+ if (waiting_synchro == nullptr) {
activity::ExecImpl* exec = new activity::ExecImpl();
- (*exec).set_name("suspend").set_host(host_).set_flops_amount(0.0).start();
- return activity::ExecImplPtr(exec);
+ exec->set_name("suspend").set_host(host_).set_flops_amount(0.0).start();
+ waiting_synchro = activity::ExecImplPtr(exec);
+
+ waiting_synchro->simcalls_.push_back(&simcall);
}
+ waiting_synchro->suspend();
}
void ActorImpl::resume()
return simgrid::kernel::actor::ActorImpl::attach(name, data, sg_host_by_name(hostname), properties).get();
}
-void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t actor)
-{
- smx_activity_t sync_suspend = actor->suspend(simcall->issuer);
-
- if (actor != simcall->issuer) {
- simcall->issuer->simcall_answer();
- } else {
- sync_suspend->simcalls_.push_back(simcall);
- actor->waiting_synchro = sync_suspend;
- actor->waiting_synchro->suspend();
- }
- /* If we are suspending ourselves, then just do not finish the simcall now */
-}
-
int SIMIX_process_count()
{
return simix_global->process_list.size();
void daemonize();
bool is_suspended() { return suspended_; }
s4u::Actor* restart();
- activity::ActivityImplPtr suspend(ActorImpl* issuer);
+ void suspend(ActorImpl* issuer);
void resume();
activity::ActivityImplPtr join(ActorImpl* actor, double timeout);
activity::ActivityImplPtr sleep(double duration);
void Actor::suspend()
{
+ auto issuer = SIMIX_process_self();
+ auto target = pimpl_;
s4u::Actor::on_suspend(*this);
- simcall_process_suspend(pimpl_);
+ simix::simcall_blocking([issuer, target]() {
+ target->suspend(issuer);
+ if (target != issuer) {
+ /* If we are suspending ourselves, then just do not finish the simcall now */
+ issuer->simcall_answer();
+ }
+ });
}
void Actor::resume()
void suspend()
{
- kernel::actor::ActorImpl* actor = SIMIX_process_self();
- Actor::on_suspend(*actor->ciface());
-
- simcall_process_suspend(actor);
+ SIMIX_process_self()->iface()->suspend();
}
void resume()
SIMIX_process_self()->join(process, timeout);
}
-/**
- * @ingroup simix_process_management
- * @brief Suspends an actor
- */
void simcall_process_suspend(smx_actor_t process)
{
- simcall_BODY_process_suspend(process);
+ SIMIX_process_self()->iface()->suspend();
}
e_smx_state_t simcall_process_sleep(double duration)
*/
#include "src/simix/popping_private.hpp"
-static inline smx_actor_t simcall_process_suspend__get__process(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_suspend__getraw__process(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_suspend__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
- simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
-}
-
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_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 simgrid::simix::unmarshal<R>(self->simcall.result);
}
-inline static void simcall_BODY_process_suspend(smx_actor_t process)
-{
- if (0) /* Go to that function to follow the code flow through the simcall barrier */
- simcall_HANDLER_process_suspend(&SIMIX_process_self()->simcall, process);
- return simcall<void, smx_actor_t>(SIMCALL_PROCESS_SUSPEND, process);
-}
-
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_EXECUTION_WAIT,
SIMCALL_EXECUTION_WAITANY_FOR,
SIMCALL_EXECUTION_TEST,
/** @brief Simcalls' names (generated from src/simix/simcalls.in) */
const char* simcall_names[] = {
"SIMCALL_NONE",
- "SIMCALL_PROCESS_SUSPEND",
"SIMCALL_EXECUTION_WAIT",
"SIMCALL_EXECUTION_WAITANY_FOR",
"SIMCALL_EXECUTION_TEST",
if (context_->iwannadie)
return;
switch (simcall.call) {
- case SIMCALL_PROCESS_SUSPEND:
- simcall_HANDLER_process_suspend(&simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall.args[0]));
- break;
-
case SIMCALL_EXECUTION_WAIT:
simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args[0]));
break;
# Last but not the least, you should declare the new simix call in
# ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
-void process_suspend(smx_actor_t process) [[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]];
bool execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]];