SwappedContext* context = static_cast<SwappedContext*>(process->context_);
context->resume();
},
- simix_global->process_to_run);
+ simix_global->actors_to_run);
} else { // sequential execution
- if (simix_global->process_to_run.empty())
+ if (simix_global->actors_to_run.empty())
return;
/* maestro is already saved in the first slot of workers_context_ */
- smx_actor_t first_actor = simix_global->process_to_run.front();
+ smx_actor_t first_actor = simix_global->actors_to_run.front();
process_index_ = 1;
/* execute the first actor; it will chain to the others when using suspend() */
static_cast<SwappedContext*>(first_actor->context_)->resume();
unsigned long int i = factory_->process_index_;
factory_->process_index_++;
- if (i < simix_global->process_to_run.size()) {
+ if (i < simix_global->actors_to_run.size()) {
/* Actually swap into the next actor directly without transiting to maestro */
XBT_DEBUG("Run next actor");
- next_context = static_cast<SwappedContext*>(simix_global->process_to_run[i]->context_);
+ next_context = static_cast<SwappedContext*>(simix_global->actors_to_run[i]->context_);
} else {
/* all processes were run, actually return to maestro */
XBT_DEBUG("No more actors to run");
void SerialThreadContext::run_all()
{
- for (smx_actor_t const& actor : simix_global->process_to_run) {
+ for (smx_actor_t const& actor : simix_global->actors_to_run) {
XBT_DEBUG("Handling %p", actor);
ThreadContext* context = static_cast<ThreadContext*>(actor->context_);
context->release();
void ParallelThreadContext::run_all()
{
- for (smx_actor_t const& actor : simix_global->process_to_run)
+ for (smx_actor_t const& actor : simix_global->actors_to_run)
static_cast<ThreadContext*>(actor->context_)->release();
- for (smx_actor_t const& actor : simix_global->process_to_run)
+ for (smx_actor_t const& actor : simix_global->actors_to_run)
static_cast<ThreadContext*>(actor->context_)->wait();
}
#if SIMGRID_HAVE_MC
xbt_assert(mc_model_checker == nullptr, "This must be called from the client");
#endif
- while (not simix_global->process_to_run.empty()) {
- SIMIX_process_runall();
- for (smx_actor_t const& process : simix_global->process_that_ran) {
+ while (not simix_global->actors_to_run.empty()) {
+ simix_global->run_all_actors();
+ for (smx_actor_t const& process : simix_global->actors_that_ran) {
smx_simcall_t req = &process->simcall;
if (req->call != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
SIMIX_simcall_handle(req, 0);
* (copy of `simix_global->process_list`);
*
* - `model_checker->process.smx_old_process_infos`
- * (copy of `simix_global->process_to_destroy`);
+ * (copy of `simix_global->actors_to_destroy`);
*
* - `model_checker->hostnames`.
*
*/
std::vector<ActorInformation> smx_actors_infos;
- /** Copy of `simix_global->process_to_destroy`
+ /** Copy of `simix_global->actors_to_destroy`
*
* See mc_smx.c.
*/
#if SIMGRID_HAVE_MC
xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process);
#endif
- simix_global->process_to_destroy.push_back(*process);
+ simix_global->actors_to_destroy.push_back(*process);
}
process->context_->iwannadie = false;
simix_global->mutex.unlock();
}
-/**
- * Garbage collection
- *
- * Should be called some time to time to free the memory allocated for processes that have finished (or killed).
- */
-void SIMIX_process_empty_trash()
-{
- while (not simix_global->process_to_destroy.empty()) {
- smx_actor_t process = &simix_global->process_to_destroy.front();
- simix_global->process_to_destroy.pop_front();
- XBT_DEBUG("Getting rid of %p",process);
- intrusive_ptr_release(process);
- }
-#if SIMGRID_HAVE_MC
- xbt_dynar_reset(simix_global->dead_actors_vector);
-#endif
-}
-
namespace simgrid {
namespace kernel {
namespace actor {
actor->exit();
- if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), actor) ==
- end(simix_global->process_to_run) &&
+ if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), actor) ==
+ end(simix_global->actors_to_run) &&
actor != this) {
XBT_DEBUG("Inserting %s in the to_run list", actor->get_cname());
- simix_global->process_to_run.push_back(actor);
+ simix_global->actors_to_run.push_back(actor);
}
}
boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(waiting_synchro);
if (sleep != nullptr) {
SIMIX_process_sleep_destroy(waiting_synchro);
- if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), this) ==
- end(simix_global->process_to_run) &&
+ if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), this) ==
+ end(simix_global->actors_to_run) &&
this != SIMIX_process_self()) {
XBT_DEBUG("Inserting [%p] %s in the to_run list", this, get_cname());
- simix_global->process_to_run.push_back(this);
+ simix_global->actors_to_run.push_back(this);
}
}
/* Now insert it in the global process list and in the process to run list */
simix_global->process_list[actor->pid_] = actor;
XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), host->get_cname());
- simix_global->process_to_run.push_back(actor);
+ simix_global->actors_to_run.push_back(actor);
intrusive_ptr_add_ref(actor);
/* The on_creation() signal must be delayed until there, where the pid and everything is set */
/* Now insert it in the global process list and in the process to run list */
simix_global->process_list[actor->pid_] = actor;
XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), host->get_cname());
- simix_global->process_to_run.push_back(actor);
+ simix_global->actors_to_run.push_back(actor);
intrusive_ptr_add_ref(actor);
auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(actor->context_);
context->attach_stop();
}
-/**
- * @brief Executes the processes from simix_global->process_to_run.
- *
- * The processes of simix_global->process_to_run are run (in parallel if
- * possible). On exit, simix_global->process_to_run is empty, and
- * simix_global->process_that_ran contains the list of processes that just ran.
- * The two lists are swapped so, be careful when using them before and after a
- * call to this function.
- */
-void SIMIX_process_runall()
-{
- SIMIX_context_runall();
-
- simix_global->process_to_run.swap(simix_global->process_that_ran);
- simix_global->process_to_run.clear();
-}
/** @deprecated When this function gets removed, also remove the xbt_ex class, that is only there to help users to
* transition */
boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro);
if (sleep != nullptr) {
SIMIX_process_sleep_destroy(actor->waiting_synchro);
- if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), actor) ==
- end(simix_global->process_to_run) &&
+ if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), actor) ==
+ end(simix_global->actors_to_run) &&
actor != SIMIX_process_self()) {
XBT_DEBUG("Inserting [%p] %s in the to_run list", actor, actor->get_cname());
- simix_global->process_to_run.push_back(actor);
+ simix_global->actors_to_run.push_back(actor);
}
}
*/
const std::vector<smx_actor_t>& simgrid::simix::process_get_runnable()
{
- return simix_global->process_to_run;
+ return simix_global->actors_to_run;
}
/** @brief Returns the process from PID. */
void set_auto_restart(bool autorestart) { auto_restart_ = autorestart; }
void set_kill_time(double kill_time);
boost::intrusive::list_member_hook<> host_process_list_hook; /* simgrid::simix::Host::process_list */
- boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->process_to_destroy */
+ boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->actors_to_destroy */
boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */
aid_t pid_ = 0;
typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
-XBT_PRIVATE void SIMIX_process_runall();
XBT_PRIVATE void SIMIX_process_cleanup(smx_actor_t arg);
-XBT_PRIVATE void SIMIX_process_empty_trash();
XBT_PRIVATE void SIMIX_process_yield(smx_actor_t self);
extern void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr actor);
simcall->issuer->simcall.call = SIMCALL_NONE;
#if 0
/* This check should be useless and slows everyone. Reactivate if you see something weird in process scheduling. */
- if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), simcall->issuer) !=
- end(simix_global->process_to_run))
+ if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), simcall->issuer) !=
+ end(simix_global->actors_to_run))
DIE_IMPOSSIBLE;
#endif
- simix_global->process_to_run.push_back(simcall->issuer);
+ simix_global->actors_to_run.push_back(simcall->issuer);
}
}
namespace simgrid {
namespace simix {
+void Global::empty_trash()
+{
+ while (not actors_to_destroy.empty()) {
+ smx_actor_t actor = &actors_to_destroy.front();
+ actors_to_destroy.pop_front();
+ XBT_DEBUG("Getting rid of %p", actor);
+ intrusive_ptr_release(actor);
+ }
+#if SIMGRID_HAVE_MC
+ xbt_dynar_reset(simix_global->dead_actors_vector);
+#endif
+}
+/**
+ * @brief Executes the actors in simix_global->actors_to_run.
+ *
+ * The actors in simix_global->actors_to_run are run (in parallel if possible). On exit, simix_global->actors_to_run
+ * is empty, and simix_global->actors_that_ran contains the list of actors that just ran.
+ * The two lists are swapped so, be careful when using them before and after a call to this function.
+ */
+void Global::run_all_actors()
+{
+ SIMIX_context_runall();
+
+ simix_global->actors_to_run.swap(simix_global->actors_that_ran);
+ simix_global->actors_to_run.clear();
+}
+
simgrid::config::Flag<double> breakpoint{"simix/breakpoint",
"When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
}
smx_cleaned = 1;
XBT_DEBUG("SIMIX_clean called. Simulation's over.");
- if (not simix_global->process_to_run.empty() && SIMIX_get_clock() <= 0.0) {
+ if (not simix_global->actors_to_run.empty() && SIMIX_get_clock() <= 0.0) {
XBT_CRITICAL(" ");
XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
/* Kill all processes (but maestro) */
simix_global->maestro_process->kill_all();
SIMIX_context_runall();
- SIMIX_process_empty_trash();
+ simix_global->empty_trash();
/* Exit the SIMIX network module */
SIMIX_mailbox_exit();
simix_timers.pop();
}
/* Free the remaining data structures */
- simix_global->process_to_run.clear();
- simix_global->process_that_ran.clear();
- simix_global->process_to_destroy.clear();
+ simix_global->actors_to_run.clear();
+ simix_global->actors_that_ran.clear();
+ simix_global->actors_to_destroy.clear();
simix_global->process_list.clear();
#if SIMGRID_HAVE_MC
bool result = false;
while (not simix_timers.empty() && SIMIX_get_clock() >= simix_timers.top().first) {
result = true;
- // FIXME: make the timers being real callbacks
- // (i.e. provide dispatchers that read and expand the args)
+ // FIXME: make the timers being real callbacks (i.e. provide dispatchers that read and expand the args)
smx_timer_t timer = simix_timers.top().second;
simix_timers.pop();
try {
double time = 0;
do {
- XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->process_to_run.size());
+ XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
if (simgrid::simix::breakpoint >= 0.0 && surf_get_clock() >= simgrid::simix::breakpoint) {
XBT_DEBUG("Breakpoint reached (%g)", simgrid::simix::breakpoint.get());
SIMIX_execute_tasks();
- while (not simix_global->process_to_run.empty()) {
- XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", simix_global->process_to_run.size());
+ while (not simix_global->actors_to_run.empty()) {
+ XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
/* Run all processes that are ready to run, possibly in parallel */
- SIMIX_process_runall();
+ simix_global->run_all_actors();
/* answer sequentially and in a fixed arbitrary order all the simcalls that were issued during that sub-round */
/* Here, the order is ok because:
*
- * Short proof: only maestro adds stuff to the process_to_run array, so the execution order of user contexts do
+ * Short proof: only maestro adds stuff to the actors_to_run array, so the execution order of user contexts do
* not impact its order.
*
* Long proof: processes remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
*
* - if there is no kill during the simulation, processes remain sorted according by their PID.
* Rationale: This can be proved inductively.
- * Assume that process_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
+ * Assume that actors_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
* is parsed linearly).
* Let's show that it is still so at the end of this round.
* - if a process is added when being created, that's from maestro. It can be either at startup
* time (and then in PID order), or in response to a process_create simcall. Since simcalls are handled
* in arbitrary order (inductive hypothesis), we are fine.
* - If a process is added because it's getting killed, its subsequent actions shouldn't matter
- * - If a process gets added to process_to_run because one of their blocking action constituting the meat
+ * - If a process gets added to actors_to_run because one of their blocking action constituting the meat
* of a simcall terminates, we're still good. Proof:
* - You are added from SIMIX_simcall_answer() only. When this function is called depends on the resource
* kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications as an
* and the argument is very similar to the previous one.
* So, in any case, the orders of calls to SIMIX_comm_finish() do not depend on the order in which user
* processes are executed.
- * So, in any cases, the orders of processes within process_to_run do not depend on the order in which
+ * So, in any cases, the orders of processes within actors_to_run do not depend on the order in which
* user processes were executed previously.
* So, if there is no killing in the simulation, the simulation reproducibility is not jeopardized.
* - If there is some process killings, the order is changed by this decision that comes from user-land
*
* So science works, bitches [http://xkcd.com/54/].
*
- * We could sort the process_that_ran array completely so that we can describe the order in which simcalls are
+ * We could sort the actors_that_ran array completely so that we can describe the order in which simcalls are
* handled (like "according to the PID of issuer"), but it's not mandatory (order is fixed already even if
* unfriendly).
* That would thus be a pure waste of time.
*/
- for (smx_actor_t const& process : simix_global->process_that_ran) {
+ for (smx_actor_t const& process : simix_global->actors_that_ran) {
if (process->simcall.call != SIMCALL_NONE) {
SIMIX_simcall_handle(&process->simcall, 0);
}
SIMIX_wake_processes();
} while (again);
- /* Clean processes to destroy */
- SIMIX_process_empty_trash();
+ /* Clean actors to destroy */
+ simix_global->empty_trash();
XBT_DEBUG("### time %f, #processes %zu, #to_run %zu", time, simix_global->process_list.size(),
- simix_global->process_to_run.size());
+ simix_global->actors_to_run.size());
- } while (time > -1.0 || not simix_global->process_to_run.empty());
+ } while (time > -1.0 || not simix_global->actors_to_run.empty());
if (not simix_global->process_list.empty()) {
friend XBT_PUBLIC bool simgrid::s4u::this_actor::is_maestro();
public:
+ /**
+ * Garbage collection
+ *
+ * Should be called some time to time to free the memory allocated for actors that have finished (or killed).
+ */
+ void empty_trash();
+ void run_all_actors();
+
smx_context_factory_t context_factory = nullptr;
- std::vector<smx_actor_t> process_to_run;
- std::vector<smx_actor_t> process_that_ran;
+ std::vector<smx_actor_t> actors_to_run;
+ std::vector<smx_actor_t> actors_that_ran;
std::map<aid_t, smx_actor_t> process_list;
boost::intrusive::list<kernel::actor::ActorImpl,
boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
&kernel::actor::ActorImpl::smx_destroy_list_hook>>
- process_to_destroy;
+ actors_to_destroy;
#if SIMGRID_HAVE_MC
- /* MCer cannot read members process_list and process_to_destroy above in the remote process, so we copy the info it
+ /* MCer cannot read members process_list and actors_to_destroy above in the remote process, so we copy the info it
* needs in a dynar.
* FIXME: This is supposed to be a temporary hack.
* A better solution would be to change the split between MCer and MCed, where the responsibility