I'm sick of snake casing, this one will have to wait.
void yield();
/** Returns true if the actor is suspended. */
- int is_suspended();
+ bool is_suspended();
/** If set to true, the actor will automatically restart when its host reboots */
void set_auto_restart(bool autorestart);
void JavaContextFactory::run_all()
{
for (smx_actor_t const& process : simgrid::simix::process_get_runnable()) {
- static_cast<JavaContext*>(process->context)->resume();
+ static_cast<JavaContext*>(process->context_)->resume();
}
}
jobject jprocess_from_native(msg_process_t process)
{
- simgrid::kernel::context::JavaContext* context = (simgrid::kernel::context::JavaContext*)process->get_impl()->context;
+ simgrid::kernel::context_::JavaContext* context =
+ (simgrid::kernel::context_::JavaContext*)process->get_impl()->context_;
return context->jprocess;
}
jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
const char* name = env->GetStringUTFChars(jname, 0);
msg_process_t process =
- MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); },
+ MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context_::java_main_jprocess(jprocess); },
/*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
env->ReleaseStringUTFChars(jname, name);
mutex->unlock(issuer);
}
- synchro = SIMIX_synchro_wait(issuer->host, timeout);
+ synchro = SIMIX_synchro_wait(issuer->host_, timeout);
synchro->simcalls_.push_front(simcall);
issuer->waiting_synchro = synchro;
cond->sleeping.push_back(*simcall->issuer);
if (this->locked) {
/* FIXME: check if the host is active ? */
/* Somebody using the mutex, use a synchronization to get host failures */
- synchro = SIMIX_synchro_wait(issuer->host, -1);
+ synchro = SIMIX_synchro_wait(issuer->host_, -1);
synchro->simcalls_.push_back(&issuer->simcall);
issuer->waiting_synchro = synchro;
this->sleeping.push_back(*issuer);
/* If the mutex is not owned by the issuer, that's not good */
if (issuer != this->owner)
THROWF(mismatch_error, 0, "Cannot release that mutex: it was locked by %s (pid:%ld), not by you.",
- this->owner->get_cname(), this->owner->pid);
+ this->owner->get_cname(), this->owner->pid_);
if (not this->sleeping.empty()) {
/*process to wake up */
e_smx_state_t result;
switch (surf_sleep->get_state()) {
case simgrid::kernel::resource::Action::State::FAILED:
- simcall->issuer->context->iwannadie = 1;
+ simcall->issuer->context_->iwannadie = 1;
result = SIMIX_SRC_HOST_FAILURE;
break;
THROW_IMPOSSIBLE;
break;
}
- if (simcall->issuer->host->is_off()) {
- simcall->issuer->context->iwannadie = 1;
+ if (simcall->issuer->host_->is_off()) {
+ simcall->issuer->context_->iwannadie = 1;
}
simcall_process_sleep__set__result(simcall, result);
simcall->issuer->waiting_synchro = nullptr;
- if (simcall->issuer->suspended) {
+ if (simcall->issuer->suspended_) {
XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
- simcall->issuer->suspended = 0;
+ simcall->issuer->suspended_ = 0;
simcall_HANDLER_process_suspend(simcall, simcall->issuer);
} else {
SIMIX_simcall_answer(simcall);
{
if (this->cleanup_func_)
this->cleanup_func_(this->process_);
- this->process_->suspended = 0;
+ this->process_->suspended_ = 0;
this->iwannadie = false;
simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->process_); });
#endif
ASAN_ONLY(this->asan_stack_ = stack);
#if BOOST_VERSION < 106100
- this->fc_ = boost::context::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper);
+ this->fc_ = boost::context_::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper);
#else
this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper);
#endif
} else {
#if BOOST_VERSION < 105600
- this->fc_ = new boost::context::fcontext_t();
+ this->fc_ = new boost::context_::fcontext_t();
#endif
if (BoostContext::maestro_context_ == nullptr)
BoostContext::maestro_context_ = this;
void BoostContext::wrapper(BoostContext::arg_type arg)
{
#if BOOST_VERSION < 106100
- BoostContext* context = reinterpret_cast<BoostContext*>(arg);
+ BoostContext* context_ = reinterpret_cast<BoostContext*>(arg);
#else
BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
- ASAN_ONLY(xbt_assert(context->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+ ASAN_ONLY(xbt_assert(context_->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
+ ASAN_FINISH_SWITCH(nullptr, &context_->asan_ctx_->asan_stack_, &context_->asan_ctx_->asan_stack_size_);
static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
#endif
try {
} catch (StopRequest const&) {
XBT_DEBUG("Caught a StopRequest");
}
- ASAN_ONLY(context->asan_stop_ = true);
+ ASAN_ONLY(context_->asan_stop_ = true);
context->suspend();
}
inline void BoostContext::swap(BoostContext* from, BoostContext* to)
{
#if BOOST_VERSION < 105600
- boost::context::jump_fcontext(from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
+ boost::context_::jump_fcontext(from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
#elif BOOST_VERSION < 106100
- boost::context::jump_fcontext(&from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
+ boost::context_::jump_fcontext(&from->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
#else
BoostContext* ctx[2] = {from, to};
ASAN_ONLY(void* fake_stack = nullptr);
if (i < simix_global->process_to_run.size()) {
/* execute the next process */
XBT_DEBUG("Run next process");
- next_context = static_cast<SerialBoostContext*>(simix_global->process_to_run[i]->context);
+ next_context = static_cast<SerialBoostContext*>(simix_global->process_to_run[i]->context_);
} else {
/* all processes were run, return to maestro */
XBT_DEBUG("No more process to run");
smx_actor_t first_process = simix_global->process_to_run.front();
process_index_ = 1;
/* execute the first process */
- static_cast<SerialBoostContext*>(first_process->context)->resume();
+ static_cast<SerialBoostContext*>(first_process->context_)->resume();
}
// ParallelBoostContext
parmap_ = new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
parmap_->apply(
[](smx_actor_t process) {
- ParallelBoostContext* context = static_cast<ParallelBoostContext*>(process->context);
+ ParallelBoostContext* context = static_cast<ParallelBoostContext*>(process->context_);
context->resume();
},
simix_global->process_to_run);
ParallelBoostContext* next_context;
if (next_work) {
XBT_DEBUG("Run next process");
- next_context = static_cast<ParallelBoostContext*>(next_work.get()->context);
+ next_context = static_cast<ParallelBoostContext*>(next_work.get()->context_);
} else {
XBT_DEBUG("No more processes to run");
uintptr_t worker_id = reinterpret_cast<uintptr_t>(xbt_os_thread_get_specific(worker_id_key_));
void RawContext::wrapper(void* arg)
{
RawContext* context = static_cast<RawContext*>(arg);
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+ ASAN_FINISH_SWITCH(nullptr, &context_->asan_ctx_->asan_stack_, &context_->asan_ctx_->asan_stack_size_);
try {
(*context)();
context->Context::stop();
} catch (StopRequest const&) {
XBT_DEBUG("Caught a StopRequest");
}
- ASAN_ONLY(context->asan_stop_ = true);
+ ASAN_ONLY(context_->asan_stop_ = true);
context->suspend();
}
if (i < simix_global->process_to_run.size()) {
/* execute the next process */
XBT_DEBUG("Run next process");
- next_context = static_cast<SerialRawContext*>(simix_global->process_to_run[i]->context);
+ next_context = static_cast<SerialRawContext*>(simix_global->process_to_run[i]->context_);
} else {
/* all processes were run, return to maestro */
XBT_DEBUG("No more process to run");
return;
smx_actor_t first_process = simix_global->process_to_run.front();
process_index_ = 1;
- static_cast<SerialRawContext*>(first_process->context)->resume();
+ static_cast<SerialRawContext*>(first_process->context_)->resume();
}
// ParallelRawContext
parmap_ = new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
parmap_->apply(
[](smx_actor_t process) {
- ParallelRawContext* context = static_cast<ParallelRawContext*>(process->context);
+ ParallelRawContext* context = static_cast<ParallelRawContext*>(process->context_);
context->resume();
},
simix_global->process_to_run);
if (next_work) {
/* there is a next process to resume */
XBT_DEBUG("Run next process");
- next_context = static_cast<ParallelRawContext*>(next_work.get()->context);
+ next_context = static_cast<ParallelRawContext*>(next_work.get()->context_);
} else {
/* all processes were run, go to the barrier */
XBT_DEBUG("No more processes to run");
void ThreadContext::attach_start()
{
// We're breaking the layers here by depending on the upper layer:
- ThreadContext* maestro = (ThreadContext*) simix_global->maestro_process->context;
+ ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
xbt_os_sem_release(maestro->begin_);
xbt_assert(not this->isMaestro());
this->start();
xbt_assert(not this->isMaestro());
this->yield();
- ThreadContext* maestro = (ThreadContext*) simix_global->maestro_process->context;
+ ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
xbt_os_sem_acquire(maestro->end_);
xbt_os_thread_set_extra_data(nullptr);
{
for (smx_actor_t const& process : simix_global->process_to_run) {
XBT_DEBUG("Handling %p", process);
- ThreadContext* context = static_cast<ThreadContext*>(process->context);
+ ThreadContext* context = static_cast<ThreadContext*>(process->context_);
context->release();
context->wait();
}
void ParallelThreadContext::run_all()
{
for (smx_actor_t const& process : simix_global->process_to_run)
- static_cast<ThreadContext*>(process->context)->release();
+ static_cast<ThreadContext*>(process->context_)->release();
for (smx_actor_t const& process : simix_global->process_to_run)
- static_cast<ThreadContext*>(process->context)->wait();
+ static_cast<ThreadContext*>(process->context_)->wait();
}
void ParallelThreadContext::start_hook()
simgrid::kernel::context::UContext* context;
memcpy(&context, ctx_addr, sizeof context);
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+ ASAN_FINISH_SWITCH(nullptr, &context_->asan_ctx_->asan_stack_, &context_->asan_ctx_->asan_stack_size_);
try {
(*context)();
context->Context::stop();
} catch (simgrid::kernel::context::Context::StopRequest const&) {
XBT_DEBUG("Caught a StopRequest");
}
- ASAN_ONLY(context->asan_stop_ = true);
+ ASAN_ONLY(context_->asan_stop_ = true);
context->suspend();
}
if (i < simix_global->process_to_run.size()) {
/* execute the next process */
XBT_DEBUG("Run next process");
- next_context = static_cast<SerialUContext*>(simix_global->process_to_run[i]->context);
+ next_context = static_cast<SerialUContext*>(simix_global->process_to_run[i]->context_);
} else {
/* all processes were run, return to maestro */
XBT_DEBUG("No more process to run");
return;
smx_actor_t first_process = simix_global->process_to_run.front();
process_index_ = 1;
- static_cast<SerialUContext*>(first_process->context)->resume();
+ static_cast<SerialUContext*>(first_process->context_)->resume();
}
// ParallelUContext
parmap_ = new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
parmap_->apply(
[](smx_actor_t process) {
- ParallelUContext* context = static_cast<ParallelUContext*>(process->context);
+ ParallelUContext* context = static_cast<ParallelUContext*>(process->context_);
context->resume();
},
simix_global->process_to_run);
if (next_work) {
// There is a next soul to embody (ie, a next process to resume)
XBT_DEBUG("Run next process");
- next_context = static_cast<ParallelUContext*>(next_work.get()->context);
+ next_context = static_cast<ParallelUContext*>(next_work.get()->context_);
} else {
// All processes were run, go to the barrier
XBT_DEBUG("No more processes to run");
smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->src_proc));
smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc));
- comm_pattern->src_proc = src_proc->pid;
- comm_pattern->dst_proc = dst_proc->pid;
+ comm_pattern->src_proc = src_proc->pid_;
+ comm_pattern->dst_proc = dst_proc->pid_;
comm_pattern->src_host = MC_smx_actor_get_host_name(src_proc);
comm_pattern->dst_host = MC_smx_actor_get_host_name(dst_proc);
if (comm_pattern->data.size() == 0 && comm->src_buff != nullptr) {
{
const smx_actor_t issuer = MC_smx_simcall_get_issuer(request);
simgrid::mc::PatternCommunicationList* initial_pattern =
- xbt_dynar_get_as(initial_communications_pattern, issuer->pid, simgrid::mc::PatternCommunicationList*);
- xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
+ xbt_dynar_get_as(initial_communications_pattern, issuer->pid_, simgrid::mc::PatternCommunicationList*);
+ xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid_, xbt_dynar_t);
std::unique_ptr<simgrid::mc::PatternCommunication> pattern =
std::unique_ptr<simgrid::mc::PatternCommunication>(new simgrid::mc::PatternCommunication());
char* remote_name = mc_model_checker->process().read<char*>(
RemotePtr<char*>((uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_)));
pattern->rdv = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
- pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid;
+ pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid_;
pattern->src_host = MC_smx_actor_get_host_name(issuer);
simgrid::smpi::Request mpi_request = mc_model_checker->process().read<simgrid::smpi::Request>(
&remote_name, remote(comm->mbox ? &simgrid::xbt::string::to_string_data(comm->mbox->name_).data
: &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data));
pattern->rdv = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
- pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid;
+ pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid_;
pattern->dst_host = MC_smx_actor_get_host_name(issuer);
} else
xbt_die("Unexpected call_type %i", (int) call_type);
- XBT_DEBUG("Insert incomplete comm pattern %p for process %ld", pattern.get(), issuer->pid);
- xbt_dynar_t dynar = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
+ XBT_DEBUG("Insert incomplete comm pattern %p for process %ld", pattern.get(), issuer->pid_);
+ xbt_dynar_t dynar = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid_, xbt_dynar_t);
simgrid::mc::PatternCommunication* pattern2 = pattern.release();
xbt_dynar_push(dynar, &pattern2);
}
state->num);
}
- if (not prev_state->actorStates[issuer->pid].isDone())
+ if (not prev_state->actorStates[issuer->pid_].isDone())
prev_state->addInterleavingSet(issuer);
else
XBT_DEBUG("Process %p is in done set", req->issuer);
const smx_actor_t previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req);
XBT_DEBUG("Simcall %d, process %ld (state %d) and simcall %d, process %ld (state %d) are independent",
- req->call, issuer->pid, state->num,
- prev_state->internal_req.call,
- previous_issuer->pid,
+ req->call, issuer->pid_, state->num, prev_state->internal_req.call, previous_issuer->pid_,
prev_state->num);
-
}
}
}
#if SIMGRID_HAVE_MC
// If in the MCer, ask the client app since it has all the data
if (mc_model_checker != nullptr) {
- return mc_model_checker->process().actor_is_enabled(actor->pid);
+ return mc_model_checker->process().actor_is_enabled(actor->pid_);
}
#endif
if (mutex->owner == nullptr)
return true;
- return mutex->owner->pid == req->issuer->pid;
+ return mutex->owner->pid_ == req->issuer->pid_;
}
case SIMCALL_SEM_ACQUIRE: {
-/* Copyright (c) 2008-2018. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2008-2018. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
std::shared_ptr<simgrid::mc::Snapshot> snapshot = std::make_shared<simgrid::mc::Snapshot>(mc_process, num_state);
for (auto const& p : mc_model_checker->process().actors())
- snapshot->enabled_processes.insert(p.copy.getBuffer()->pid);
+ snapshot->enabled_processes.insert(p.copy.getBuffer()->pid_);
snapshot_handle_ignore(snapshot.get());
value, sizeof(comm_addr));
comm_addr = remote(addr);
}
- checker->complete_comm_pattern(pattern, comm_addr,
- MC_smx_simcall_get_issuer(req)->pid, backtracking);
+ checker->complete_comm_pattern(pattern, comm_addr, MC_smx_simcall_get_issuer(req)->pid_, backtracking);
}
break;
default:
if (simgrid::mc::processes_time.empty())
return 0;
if (process != nullptr)
- return simgrid::mc::processes_time[process->pid];
+ return simgrid::mc::processes_time[process->pid_];
return -1;
}
void MC_process_clock_add(smx_actor_t process, double amount)
{
- simgrid::mc::processes_time[process->pid] += amount;
+ simgrid::mc::processes_time[process->pid_] += amount;
}
type = "iSend";
char* p = pointer_to_string(simcall_comm_isend__get__src_buff(req));
char* bs = buff_size_to_string(simcall_comm_isend__get__src_buff_size(req));
- if (issuer->host)
- args = bprintf("src=(%ld)%s (%s), buff=%s, size=%s", issuer->pid, MC_smx_actor_get_host_name(issuer),
+ if (issuer->host_)
+ args = bprintf("src=(%ld)%s (%s), buff=%s, size=%s", issuer->pid_, MC_smx_actor_get_host_name(issuer),
MC_smx_actor_get_name(issuer), p, bs);
else
- args = bprintf("src=(%ld)%s, buff=%s, size=%s", issuer->pid, MC_smx_actor_get_name(issuer), p, bs);
+ args = bprintf("src=(%ld)%s, buff=%s, size=%s", issuer->pid_, MC_smx_actor_get_name(issuer), p, bs);
xbt_free(bs);
xbt_free(p);
break;
type = "iRecv";
char* p = pointer_to_string(simcall_comm_irecv__get__dst_buff(req));
char* bs = buff_size_to_string(size);
- if (issuer->host)
- args = bprintf("dst=(%ld)%s (%s), buff=%s, size=%s", issuer->pid, MC_smx_actor_get_host_name(issuer),
+ if (issuer->host_)
+ args = bprintf("dst=(%ld)%s (%s), buff=%s, size=%s", issuer->pid_, MC_smx_actor_get_host_name(issuer),
MC_smx_actor_get_name(issuer), p, bs);
else
- args = bprintf("dst=(%ld)%s, buff=%s, size=%s", issuer->pid, MC_smx_actor_get_name(issuer), p, bs);
+ args = bprintf("dst=(%ld)%s, buff=%s, size=%s", issuer->pid_, MC_smx_actor_get_name(issuer), p, bs);
xbt_free(bs);
xbt_free(p);
break;
smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->src_proc));
smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->dst_proc));
args =
- bprintf("comm=%s [(%ld)%s (%s)-> (%ld)%s (%s)]", p, src_proc ? src_proc->pid : 0,
+ bprintf("comm=%s [(%ld)%s (%s)-> (%ld)%s (%s)]", p, src_proc ? src_proc->pid_ : 0,
src_proc ? MC_smx_actor_get_host_name(src_proc) : "", src_proc ? MC_smx_actor_get_name(src_proc) : "",
- dst_proc ? dst_proc->pid : 0, dst_proc ? MC_smx_actor_get_host_name(dst_proc) : "",
+ dst_proc ? dst_proc->pid_ : 0, dst_proc ? MC_smx_actor_get_host_name(dst_proc) : "",
dst_proc ? MC_smx_actor_get_name(dst_proc) : "");
}
xbt_free(p);
smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->src_proc));
smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->dst_proc));
- args = bprintf("comm=%s [(%ld)%s (%s) -> (%ld)%s (%s)]", p, src_proc->pid, MC_smx_actor_get_name(src_proc),
- MC_smx_actor_get_host_name(src_proc), dst_proc->pid, MC_smx_actor_get_name(dst_proc),
+ args = bprintf("comm=%s [(%ld)%s (%s) -> (%ld)%s (%s)]", p, src_proc->pid_, MC_smx_actor_get_name(src_proc),
+ MC_smx_actor_get_host_name(src_proc), dst_proc->pid_, MC_smx_actor_get_name(dst_proc),
MC_smx_actor_get_host_name(dst_proc));
}
xbt_free(p);
args =
bprintf("locked = %d, owner = %d, sleeping = n/a", mutex.getBuffer()->locked,
mutex.getBuffer()->owner != nullptr
- ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner))->pid
+ ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner))->pid_
: -1);
break;
}
std::string str;
if (args != nullptr)
- str = simgrid::xbt::string_printf("[(%ld)%s (%s)] %s(%s)", issuer->pid, MC_smx_actor_get_host_name(issuer),
+ str = simgrid::xbt::string_printf("[(%ld)%s (%s)] %s(%s)", issuer->pid_, MC_smx_actor_get_host_name(issuer),
MC_smx_actor_get_name(issuer), type, args);
else
- str = simgrid::xbt::string_printf("[(%ld)%s (%s)] %s ", issuer->pid, MC_smx_actor_get_host_name(issuer),
+ str = simgrid::xbt::string_printf("[(%ld)%s (%s)] %s ", issuer->pid_, MC_smx_actor_get_host_name(issuer),
MC_smx_actor_get_name(issuer), type);
xbt_free(args);
return str;
switch (req->call) {
case SIMCALL_COMM_ISEND:
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] iSend", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] iSend", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = bprintf("[(%ld)] iSend", issuer->pid);
+ label = bprintf("[(%ld)] iSend", issuer->pid_);
break;
case SIMCALL_COMM_IRECV:
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] iRecv", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] iRecv", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] iRecv", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] iRecv", issuer->pid_);
break;
case SIMCALL_COMM_WAIT:
if (value == -1) {
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] WaitTimeout", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] WaitTimeout", issuer->pid_);
} else {
simgrid::kernel::activity::ActivityImpl* remote_act = simcall_comm_wait__getraw__comm(req);
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->src_proc));
smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc));
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->pid,
- MC_smx_actor_get_host_name(issuer), src_proc ? src_proc->pid : 0,
- dst_proc ? dst_proc->pid : 0);
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->pid_,
+ MC_smx_actor_get_host_name(issuer), src_proc ? src_proc->pid_ : 0,
+ dst_proc ? dst_proc->pid_ : 0);
else
- label = simgrid::xbt::string_printf("[(%ld)] Wait [(%ld)->(%ld)]",
- issuer->pid,
- src_proc ? src_proc->pid : 0,
- dst_proc ? dst_proc->pid : 0);
+ label = simgrid::xbt::string_printf("[(%ld)] Wait [(%ld)->(%ld)]", issuer->pid_, src_proc ? src_proc->pid_ : 0,
+ dst_proc ? dst_proc->pid_ : 0);
}
break;
mc_model_checker->process().read(temp_comm, remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
simgrid::kernel::activity::CommImpl* comm = temp_comm.getBuffer();
if (comm->src_proc == nullptr || comm->dst_proc == nullptr) {
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] Test FALSE", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] Test FALSE", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = bprintf("[(%ld)] Test FALSE", issuer->pid);
+ label = bprintf("[(%ld)] Test FALSE", issuer->pid_);
} else {
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] Test TRUE", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] Test TRUE", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] Test TRUE", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] Test TRUE", issuer->pid_);
}
break;
}
case SIMCALL_COMM_WAITANY: {
unsigned long comms_size = read_length(
mc_model_checker->process(), remote(simcall_comm_waitany__get__comms(req)));
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] WaitAny [%d of %lu]", issuer->pid,
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] WaitAny [%d of %lu]", issuer->pid_,
MC_smx_actor_get_host_name(issuer), value + 1, comms_size);
else
- label = simgrid::xbt::string_printf("[(%ld)] WaitAny [%d of %lu]",
- issuer->pid, value + 1, comms_size);
+ label = simgrid::xbt::string_printf("[(%ld)] WaitAny [%d of %lu]", issuer->pid_, value + 1, comms_size);
break;
}
case SIMCALL_COMM_TESTANY:
if (value == -1) {
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->pid, MC_smx_actor_get_host_name(issuer));
+ if (issuer->host_)
+ label =
+ simgrid::xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->pid_, MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] TestAny FALSE", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] TestAny FALSE", issuer->pid_);
} else {
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] TestAny TRUE [%d of %lu]", issuer->pid,
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] TestAny TRUE [%d of %lu]", issuer->pid_,
MC_smx_actor_get_host_name(issuer), value + 1,
simcall_comm_testany__get__count(req));
else
- label = simgrid::xbt::string_printf("[(%ld)] TestAny TRUE [%d of %lu]",
- issuer->pid,
- value + 1,
- simcall_comm_testany__get__count(req));
+ label = simgrid::xbt::string_printf("[(%ld)] TestAny TRUE [%d of %lu]", issuer->pid_, value + 1,
+ simcall_comm_testany__get__count(req));
}
break;
case SIMCALL_MUTEX_TRYLOCK:
- label = simgrid::xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->pid_);
break;
case SIMCALL_MUTEX_LOCK:
- label = simgrid::xbt::string_printf("[(%ld)] Mutex LOCK", issuer->pid);
+ label = simgrid::xbt::string_printf("[(%ld)] Mutex LOCK", issuer->pid_);
break;
case SIMCALL_MC_RANDOM:
- if (issuer->host)
- label = simgrid::xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->pid, MC_smx_actor_get_host_name(issuer),
+ if (issuer->host_)
+ label = simgrid::xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->pid_, MC_smx_actor_get_host_name(issuer),
value);
else
- label = simgrid::xbt::string_printf("[(%ld)] MC_RANDOM (%d)", issuer->pid, value);
+ label = simgrid::xbt::string_printf("[(%ld)] MC_RANDOM (%d)", issuer->pid_, value);
break;
default:
THROW_UNIMPLEMENTED;
}
- const char* color = get_color(issuer->pid - 1);
+ const char* color = get_color(issuer->pid_ - 1);
return simgrid::xbt::string_printf(
"label = \"%s\", color = %s, fontcolor = %s", label.c_str(),
color, color);
const char* MC_smx_actor_get_host_name(smx_actor_t actor)
{
if (mc_model_checker == nullptr)
- return actor->host->get_cname();
+ return actor->host_->get_cname();
simgrid::mc::RemoteClient* process = &mc_model_checker->process();
// Read the simgrid::xbt::string in the MCed process:
simgrid::mc::ActorInformation* info = actor_info_cast(actor);
- auto remote_string_address = remote((simgrid::xbt::string_data*)((char*)actor->host + offset));
+ auto remote_string_address = remote((simgrid::xbt::string_data*)((char*)actor->host_ + offset));
simgrid::xbt::string_data remote_string = process->read(remote_string_address);
char hostname[remote_string.len];
process->read_bytes(hostname, remote_string.len + 1, remote(remote_string.data));
{
simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (mc_model_checker == nullptr)
- return actor->name.c_str();
+ return actor->get_cname();
simgrid::mc::ActorInformation* info = actor_info_cast(actor);
if (info->name.empty()) {
- simgrid::xbt::string_data string_data = simgrid::xbt::string::to_string_data(actor->name);
+ simgrid::xbt::string_data string_data = simgrid::xbt::string::to_string_data(actor->name_);
info->name = process->read_string(remote(string_data.data), string_data.len);
}
return info->name.c_str();
static inline smx_simcall_t MC_state_get_request_for_process(simgrid::mc::State* state, smx_actor_t actor)
{
/* reset the outgoing transition */
- simgrid::mc::ProcessState* procstate = &state->actorStates[actor->pid];
+ simgrid::mc::ProcessState* procstate = &state->actorStates[actor->pid_];
state->transition.pid = -1;
state->transition.argument = -1;
state->executed_req.call = SIMCALL_NONE;
if (not req)
return nullptr;
- state->transition.pid = actor->pid;
+ state->transition.pid = actor->pid_;
state->executed_req = *req;
// Fetch the data of the request and translate it:
state->internal_req = *req;
{
for (auto& actor : mc_model_checker->process().actors()) {
/* Only consider the actors that were marked as interleaving by the checker algorithm */
- if (not state->actorStates[actor.copy.getBuffer()->pid].isTodo())
+ if (not state->actorStates[actor.copy.getBuffer()->pid_].isTodo())
continue;
smx_simcall_t res = MC_state_get_request_for_process(state, actor.copy.getBuffer());
explicit State(unsigned long state_number);
std::size_t interleaveSize() const;
- void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid].consider(); }
+ void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid_].consider(); }
Transition getTransition() const;
};
}
region.block = ((char*)stack - (char*)heap->heapbase) / BLOCKSIZE + 1;
#if HAVE_SMPI
if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP && process)
- region.process_index = process->pid - 1;
+ region.process_index = process->pid_ - 1;
else
#endif
region.process_index = -1;
msg_actor = (simgrid::msg::ActorExt*)SIMIX_process_self_get_data();
SIMIX_process_self_set_data(nullptr);
} else {
- msg_actor = (simgrid::msg::ActorExt*)smx_actor->getUserData();
+ msg_actor = (simgrid::msg::ActorExt*)smx_actor->get_user_data();
simcall_process_set_data(smx_actor, nullptr);
}
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
/* get from SIMIX the MSG process data, and then the user data */
- simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->get_impl()->getUserData();
+ simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->get_impl()->get_user_data();
if (msgExt)
return msgExt->data;
else
{
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
- static_cast<simgrid::msg::ActorExt*>(process->get_impl()->getUserData())->data = data;
+ static_cast<simgrid::msg::ActorExt*>(process->get_impl()->get_user_data())->data = data;
return MSG_OK;
}
int MSG_process_self_PID()
{
smx_actor_t self = SIMIX_process_self();
- return self == nullptr ? 0 : self->pid;
+ return self == nullptr ? 0 : self->pid_;
}
/** \ingroup m_process_management
}
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) { // deprecated -- smx_context_t should die afterward
- return process->get_impl()->context;
+ return process->get_impl()->context_;
}
/**
* \ingroup m_process_management
{
if (get_state() != s4u::VirtualMachine::state::RUNNING)
THROWF(vm_error, 0, "Cannot suspend VM %s: it is not running.", piface_->get_cname());
- if (issuer->host == piface_)
+ if (issuer->host_ == piface_)
THROWF(vm_error, 0, "Actor %s cannot suspend the VM %s in which it runs", issuer->get_cname(),
piface_->get_cname());
action_->suspend();
for (auto& smx_process : process_list) {
- XBT_DEBUG("suspend %s", smx_process.name.c_str());
+ XBT_DEBUG("suspend %s", smx_process.get_cname());
smx_process.suspend(issuer);
}
for (auto& smx_process : process_list) {
XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", smx_process.get_cname(),
- smx_process.host->get_cname(), issuer->get_cname());
+ smx_process.host_->get_cname(), issuer->get_cname());
SIMIX_process_kill(&smx_process, issuer);
}
void Actor::set_auto_restart(bool autorestart)
{
- simgrid::simix::simcall([this, autorestart]() { pimpl_->auto_restart = autorestart; });
+ simgrid::simix::simcall([this, autorestart]() { pimpl_->auto_restart_ = autorestart; });
}
void Actor::on_exit(int_f_pvoid_pvoid_t fun, void* data) /* deprecated */
s4u::Host* Actor::get_host()
{
- return this->pimpl_->host;
+ return this->pimpl_->host_;
}
void Actor::daemonize()
bool Actor::is_daemon() const
{
- return this->pimpl_->isDaemon();
+ return this->pimpl_->is_daemon();
}
const simgrid::xbt::string& Actor::get_name() const
aid_t Actor::get_pid() const
{
- return this->pimpl_->pid;
+ return this->pimpl_->pid_;
}
aid_t Actor::get_ppid() const
{
- return this->pimpl_->ppid;
+ return this->pimpl_->ppid_;
}
void Actor::suspend()
s4u::Actor::on_resume(this);
}
-int Actor::is_suspended()
+bool Actor::is_suspended()
{
- return simgrid::simix::simcall([this] { return pimpl_->suspended; });
+ return simgrid::simix::simcall([this] { return pimpl_->suspended_; });
}
void Actor::set_kill_time(double time)
aid_t get_pid()
{
- return SIMIX_process_self()->pid;
+ return SIMIX_process_self()->pid_;
}
aid_t get_ppid()
{
- return SIMIX_process_self()->ppid;
+ return SIMIX_process_self()->ppid_;
}
std::string get_name()
Host* get_host()
{
- return SIMIX_process_self()->host;
+ return SIMIX_process_self()->host_;
}
void suspend()
bool is_suspended()
{
smx_actor_t process = SIMIX_process_self();
- return simgrid::simix::simcall([process] { return process->suspended; });
+ return simgrid::simix::simcall([process] { return process->suspended_; });
}
void kill()
smx_actor_t smx_proc = SIMIX_process_self();
if (smx_proc == nullptr)
xbt_die("Cannot call Host::current() from the maestro context");
- return smx_proc->host;
+ return smx_proc->host_;
}
void Host::turn_on()
for (auto& process : host->process_list) {
SIMIX_process_kill(&process, self);
XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process.get_cname(),
- process.host->get_cname(), self->get_cname());
+ process.host_->get_cname(), self->get_cname());
}
}
sg_host_t sg_host_self()
{
smx_actor_t process = SIMIX_process_self();
- return (process == nullptr) ? nullptr : process->host;
+ return (process == nullptr) ? nullptr : process->host_;
}
*/
void SIMIX_process_cleanup(smx_actor_t process)
{
- XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", process->name.c_str(), process,
+ XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", process->get_cname(), process,
process->waiting_synchro.get());
- process->finished = true;
+ process->finished_ = true;
SIMIX_process_on_exit_runall(process);
/* Unregister from the kill timer if any */
}
XBT_DEBUG("%p should not be run anymore",process);
- simix_global->process_list.erase(process->pid);
- if (process->host && process->host_process_list_hook.is_linked())
- simgrid::xbt::intrusive_erase(process->host->extension<simgrid::simix::Host>()->process_list, *process);
+ simix_global->process_list.erase(process->pid_);
+ if (process->host_ && process->host_process_list_hook.is_linked())
+ simgrid::xbt::intrusive_erase(process->host_->extension<simgrid::simix::Host>()->process_list, *process);
if (not process->smx_destroy_list_hook.is_linked()) {
#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);
}
- process->context->iwannadie = 0;
+ process->context_->iwannadie = 0;
xbt_os_mutex_release(simix_global->mutex);
}
ActorImpl::~ActorImpl()
{
- delete this->context;
+ delete this->context_;
}
static void dying_daemon(int /*exit_status*/, void* data)
/** This process will be terminated automatically when the last non-daemon process finishes */
void ActorImpl::daemonize()
{
- if (not daemon) {
- daemon = true;
+ if (not daemon_) {
+ daemon_ = true;
simix_global->daemons.push_back(this);
SIMIX_process_on_exit(this, dying_daemon, this);
}
simgrid::s4u::Actor* ActorImpl::restart()
{
- XBT_DEBUG("Restarting process %s on %s", get_cname(), host->get_cname());
+ XBT_DEBUG("Restarting process %s on %s", get_cname(), host_->get_cname());
// retrieve the arguments of the old process
// FIXME: Factorize this with SIMIX_host_add_auto_restart_process ?
simgrid::kernel::actor::ProcessArg arg;
- arg.name = name;
+ arg.name = name_;
arg.code = code;
- arg.host = host;
+ arg.host = host_;
arg.kill_time = SIMIX_timer_get_date(kill_timer);
- arg.data = userdata;
+ arg.data = userdata_;
arg.properties = nullptr;
- arg.auto_restart = auto_restart;
+ arg.auto_restart = auto_restart_;
// kill the old process
SIMIX_process_kill(this, (this == simix_global->maestro_process) ? this : SIMIX_process_self());
if (arg.kill_time >= 0)
simcall_process_set_kill_time(actor, arg.kill_time);
if (arg.auto_restart)
- actor->auto_restart = arg.auto_restart;
+ actor->auto_restart_ = arg.auto_restart;
return actor->ciface();
}
smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
{
- if (suspended) {
- XBT_DEBUG("Actor '%s' is already suspended", name.c_str());
+ if (suspended_) {
+ XBT_DEBUG("Actor '%s' is already suspended", get_cname());
return nullptr;
}
- suspended = 1;
+ suspended_ = 1;
/* If we are suspending another actor that is waiting on a sync, suspend its synchronization. */
if (this != issuer) {
return nullptr;
} else {
- return SIMIX_execution_start("suspend", 0.0, 1.0, 0.0, this->host);
+ return SIMIX_execution_start("suspend", 0.0, 1.0, 0.0, this->host_);
}
}
{
XBT_IN("process = %p", this);
- if (context->iwannadie) {
+ if (context_->iwannadie) {
XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
return;
}
- if (not suspended)
+ if (not suspended_)
return;
- suspended = 0;
+ suspended_ = 0;
/* resume the synchronization that was blocking the resumed actor. */
if (waiting_synchro)
smx_activity_t ActorImpl::sleep(double duration)
{
- if (host->is_off())
- THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host->get_cname());
+ if (host_->is_off())
+ THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host_->get_cname());
simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
- synchro->host = host;
- synchro->surf_sleep = host->pimpl_cpu->sleep(duration);
+ synchro->host = host_;
+ synchro->surf_sleep = host_->pimpl_cpu->sleep(duration);
synchro->surf_sleep->set_data(synchro);
XBT_DEBUG("Create sleep synchronization %p", synchro);
smx_actor_t maestro = nullptr;
/* Create maestro process and initialize it */
maestro = new simgrid::kernel::actor::ActorImpl();
- maestro->pid = simix_process_maxpid++;
- maestro->name = "";
- maestro->setUserData(nullptr);
+ maestro->pid_ = simix_process_maxpid++;
+ maestro->name_ = "";
+ maestro->set_user_data(nullptr);
if (not code) {
- maestro->context = SIMIX_context_new(simgrid::simix::ActorCode(), nullptr, maestro);
+ maestro->context_ = SIMIX_context_new(simgrid::simix::ActorCode(), nullptr, maestro);
} else {
if (not simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
- maestro->context = simix_global->context_factory->create_maestro(code, maestro);
+ maestro->context_ = simix_global->context_factory->create_maestro(code, maestro);
}
maestro->simcall.issuer = maestro;
xbt_assert(code && host != nullptr, "Invalid parameters");
/* Process data */
- process->pid = simix_process_maxpid++;
- process->name = simgrid::xbt::string(name);
- process->host = host;
- process->setUserData(data);
+ process->pid_ = simix_process_maxpid++;
+ process->name_ = simgrid::xbt::string(name);
+ process->host_ = host;
+ process->set_user_data(data);
process->simcall.issuer = process;
if (parent_process != nullptr) {
- process->ppid = parent_process->pid;
+ process->ppid_ = parent_process->pid_;
}
process->code = code;
- XBT_VERB("Create context %s", process->name.c_str());
- process->context = SIMIX_context_new(std::move(code), simix_global->cleanup_process_function, process);
+ XBT_VERB("Create context %s", process->get_cname());
+ process->context_ = SIMIX_context_new(std::move(code), simix_global->cleanup_process_function, process);
/* Add properties */
if (properties != nullptr)
/* Add the process to its host's process list */
host->extension<simgrid::simix::Host>()->process_list.push_back(*process);
- XBT_DEBUG("Start context '%s'", process->name.c_str());
+ XBT_DEBUG("Start context '%s'", process->get_cname());
/* Now insert it in the global process list and in the process to run list */
- simix_global->process_list[process->pid] = process;
+ simix_global->process_list[process->pid_] = process;
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->get_cname(), host->get_cname());
simix_global->process_to_run.push_back(process);
intrusive_ptr_add_ref(process);
smx_actor_t process = new simgrid::kernel::actor::ActorImpl();
/* Process data */
- process->pid = simix_process_maxpid++;
- process->name = std::string(name);
- process->host = host;
- process->setUserData(data);
+ process->pid_ = simix_process_maxpid++;
+ process->name_ = std::string(name);
+ process->host_ = host;
+ process->set_user_data(data);
process->simcall.issuer = process;
if (parent_process != nullptr) {
- process->ppid = parent_process->pid;
+ process->ppid_ = parent_process->pid_;
}
/* Process data for auto-restart */
process->code = nullptr;
- XBT_VERB("Create context %s", process->name.c_str());
+ XBT_VERB("Create context %s", process->get_cname());
if (not simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
- process->context = simix_global->context_factory->attach(simix_global->cleanup_process_function, process);
+ process->context_ = simix_global->context_factory->attach(simix_global->cleanup_process_function, process);
/* Add properties */
if (properties != nullptr)
host->extension<simgrid::simix::Host>()->process_list.push_back(*process);
/* Now insert it in the global process list and in the process to run list */
- simix_global->process_list[process->pid] = process;
+ simix_global->process_list[process->pid_] = process;
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->get_cname(), host->get_cname());
simix_global->process_to_run.push_back(process);
intrusive_ptr_add_ref(process);
-
- auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(process->context);
+ auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(process->context_);
if (not context)
xbt_die("Not a suitable context");
*/
void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
- if (process->finished) {
+ if (process->finished_) {
XBT_DEBUG("Ignoring request to kill process %s@%s that is already dead", process->get_cname(),
- process->host->get_cname());
+ process->host_->get_cname());
return;
}
- XBT_DEBUG("Actor '%s'@%s is killing actor '%s'@%s", issuer->get_cname(), issuer->host->get_cname(),
- process->get_cname(), process->host->get_cname());
+ XBT_DEBUG("Actor '%s'@%s is killing actor '%s'@%s", issuer->get_cname(), issuer->host_->get_cname(),
+ process->get_cname(), process->host_->get_cname());
- process->context->iwannadie = 1;
- process->blocked = 0;
- process->suspended = 0;
+ process->context_->iwannadie = 1;
+ process->blocked_ = 0;
+ process->suspended_ = 0;
process->exception = nullptr;
/* destroy the blocking synchro if any */
if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), process) ==
end(simix_global->process_to_run) &&
process != issuer) {
- XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
+ XBT_DEBUG("Inserting %s in the to_run list", process->get_cname());
simix_global->process_to_run.push_back(process);
}
}
void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const char *msg) {
SMX_EXCEPTION(process, cat, value, msg);
- if (process->suspended)
+ if (process->suspended_)
process->resume();
/* cancel the blocking synchro if any */
if (std::find(begin(simix_global->process_to_run), end(simix_global->process_to_run), process) ==
end(simix_global->process_to_run) &&
process != SIMIX_process_self()) {
- XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
+ XBT_DEBUG("Inserting %s in the to_run list", process->get_cname());
simix_global->process_to_run.push_back(process);
}
}
void SIMIX_process_change_host(smx_actor_t actor, sg_host_t dest)
{
xbt_assert((actor != nullptr), "Invalid parameters");
- simgrid::xbt::intrusive_erase(actor->host->extension<simgrid::simix::Host>()->process_list, *actor);
- actor->host = dest;
+ simgrid::xbt::intrusive_erase(actor->host_->extension<simgrid::simix::Host>()->process_list, *actor);
+ actor->host_ = dest;
dest->extension<simgrid::simix::Host>()->process_list.push_back(*actor);
}
if (not self) {
return nullptr;
}
- return self->getUserData();
+ return self->get_user_data();
}
void SIMIX_process_self_set_data(void *data)
{
- SIMIX_process_self()->setUserData(data);
+ SIMIX_process_self()->set_user_data(data);
}
if (process == nullptr || process == simix_global->maestro_process)
return "maestro";
- return process->name.c_str();
+ return process->get_cname();
}
void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout)
{
- if (process->finished) {
+ if (process->finished_) {
// The joined process is already finished, just wake up the issuer process right away
simcall_process_sleep__set__result(simcall, SIMIX_DONE);
SIMIX_simcall_answer(simcall);
XBT_DEBUG("Yield actor '%s'", self->get_cname());
/* Go into sleep and return control to maestro */
- self->context->suspend();
+ self->context_->suspend();
/* Ok, maestro returned control to us */
- XBT_DEBUG("Control returned to me: '%s'", self->name.c_str());
+ XBT_DEBUG("Control returned to me: '%s'", self->get_cname());
- if (self->context->iwannadie){
+ if (self->context_->iwannadie) {
XBT_DEBUG("I wanna die!");
- self->finished = true;
+ self->finished_ = true;
/* execute the on_exit functions */
SIMIX_process_on_exit_runall(self);
/* Add the process to the list of process to restart, only if the host is down */
- if (self->auto_restart && self->host->is_off()) {
- SIMIX_host_add_auto_restart_process(self->host, self->get_cname(), self->code, self->getUserData(),
+ if (self->auto_restart_ && self->host_->is_off()) {
+ SIMIX_host_add_auto_restart_process(self->host_, self->get_cname(), self->code, self->get_user_data(),
SIMIX_timer_get_date(self->kill_timer), self->get_properties(),
- self->auto_restart);
+ self->auto_restart_);
}
- XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host->get_cname());
- self->context->stop();
+ XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host_->get_cname());
+ self->context_->stop();
}
- if (self->suspended) {
+ if (self->suspended_) {
XBT_DEBUG("Hey! I'm suspended.");
xbt_assert(self->exception != nullptr, "Gasp! This exception may be lost by subsequent calls.");
- self->suspended = 0;
+ self->suspended_ = 0;
self->suspend(self);
}
std::rethrow_exception(std::move(exception));
}
- if (SMPI_switch_data_segment && not self->finished) {
+ if (SMPI_switch_data_segment && not self->finished_) {
SMPI_switch_data_segment(self->iface());
}
}
void SIMIX_process_on_exit_runall(smx_actor_t process) {
simgrid::s4u::Actor::on_destruction(process->iface());
- smx_process_exit_status_t exit_status = (process->context->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
+ smx_process_exit_status_t exit_status = (process->context_->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
while (not process->on_exit.empty()) {
s_smx_process_exit_fun_t exit_fun = process->on_exit.back();
process->on_exit.pop_back();
* If set to 1, the process will be automatically restarted when its host comes back.
*/
void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart) {
- process->auto_restart = auto_restart;
+ process->auto_restart_ = auto_restart;
}
/** @brief Restart a process, starting it again from the beginning. */
class ProcessArg {
public:
std::string name;
- simgrid::simix::ActorCode code;
+ std::function<void()> code;
void* data = nullptr;
s4u::Host* host = nullptr;
double kill_time = 0.0;
std::shared_ptr<std::unordered_map<std::string, std::string>> properties;
bool auto_restart = false;
ProcessArg() = default;
- explicit ProcessArg(std::string name, simgrid::simix::ActorCode code, void* data, s4u::Host* host, double kill_time,
+ explicit ProcessArg(std::string name, std::function<void()> code, void* data, s4u::Host* host, double kill_time,
std::shared_ptr<std::unordered_map<std::string, std::string>> properties, bool auto_restart)
: name(name)
, code(std::move(code))
boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->process_to_destroy */
boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */
- aid_t pid = 0;
- aid_t ppid = -1;
- simgrid::xbt::string name;
- const simgrid::xbt::string& get_name() const { return name; }
- const char* get_cname() const { return name.c_str(); }
- s4u::Host* host = nullptr; /* the host on which the process is running */
- smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
+ aid_t pid_ = 0;
+ aid_t ppid_ = -1;
+ simgrid::xbt::string name_;
+ const simgrid::xbt::string& get_name() const { return name_; }
+ const char* get_cname() const { return name_.c_str(); }
+ s4u::Host* host_ = nullptr; /* the host on which the process is running */
+ smx_context_t context_ = nullptr; /* the context (uctx/raw/thread) that executes the user function */
std::exception_ptr exception;
- bool finished = false;
- bool blocked = false;
- bool suspended = false;
- bool auto_restart = false;
+ bool finished_ = false;
+ bool blocked_ = false;
+ bool suspended_ = false;
+ bool auto_restart_ = false;
smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
std::list<smx_activity_t> comms; /* the current non-blocking communication synchros */
s_smx_simcall simcall;
std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
- simgrid::simix::ActorCode code;
+ std::function<void()> code;
smx_timer_t kill_timer = nullptr;
private:
- void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */
+ void* userdata_ = nullptr; /* kept for compatibility, it should be replaced with moddata */
/* Refcounting */
std::atomic_int_fast32_t refcount_{0};
/* Daemon actors are automatically killed when the last non-daemon leaves */
private:
- bool daemon = false;
+ bool daemon_ = false;
public:
void daemonize();
- bool isDaemon() const { return daemon; } /** Whether this actor has been daemonized */
- bool isSuspended() const { return suspended; }
+ bool is_daemon() { return daemon_; } /** Whether this actor has been daemonized */
+ bool is_suspended() { return suspended_; }
simgrid::s4u::Actor* restart();
smx_activity_t suspend(ActorImpl* issuer);
void resume();
smx_activity_t sleep(double duration);
- void setUserData(void* data) { userdata = data; }
- void* getUserData() const { return userdata; }
+ void set_user_data(void* data) { userdata_ = data; }
+ void* get_user_data() { return userdata_; }
};
/* Used to keep the list of actors blocked on a synchro */
&ActorImpl::smx_synchro_hook>>
SynchroList;
-XBT_PUBLIC void create_maestro(simgrid::simix::ActorCode code);
+XBT_PUBLIC void create_maestro(std::function<void()> code);
}
} // namespace kernel
} // namespace simgrid
typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
-XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
+XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
std::unordered_map<std::string, std::string>* properties,
smx_actor_t parent_process);
*/
void simcall_process_set_data(smx_actor_t process, void *data)
{
- simgrid::simix::simcall([process, data] { process->setUserData(data); });
+ simgrid::simix::simcall([process, data] { process->set_user_data(data); });
}
/**
if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
return;
- XBT_DEBUG("Set kill time %f for process %s@%s", kill_time, process->get_cname(), process->host->get_cname());
+ XBT_DEBUG("Set kill time %f for process %s@%s", kill_time, process->get_cname(), process->host_->get_cname());
process->kill_timer = SIMIX_timer_set(kill_time, [process] {
simix_global->kill_process_function(process);
process->kill_timer=nullptr;
{
if (simcall->issuer != simix_global->maestro_process){
XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), (int)simcall->call,
- simcall->issuer->name.c_str(), simcall->issuer);
+ simcall->issuer->get_cname(), simcall->issuer);
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. */
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name.c_str(),
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
+ XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall.call),
+ (int)self->simcall.call);
SIMIX_process_yield(self);
} else {
SIMIX_simcall_handle(&self->simcall, 0);
void SIMIX_simcall_handle(smx_simcall_t simcall, int value) {
XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
SIMCALL_SET_MC_VALUE(simcall, value);
- if (simcall->issuer->context->iwannadie)
+ if (simcall->issuer->context_->iwannadie)
return;
switch (simcall->call) {
case SIMCALL_PROCESS_SUSPEND:
case NUM_SIMCALLS:
break;
case SIMCALL_NONE:
- THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
- simcall->issuer->name.c_str(),
- sg_host_get_name(simcall->issuer->host)
- );
+ THROWF(arg_error, 0, "Asked to do the noop syscall on %s@%s", simcall->issuer->get_cname(),
+ sg_host_get_name(simcall->issuer->host_));
break;
default:
THROW_IMPOSSIBLE;
' XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));\n')
fd.write(' SIMCALL_SET_MC_VALUE(simcall, value);\n')
fd.write(
- ' if (simcall->issuer->context->iwannadie)\n')
+ ' if (simcall->issuer->context_->iwannadie)\n')
fd.write(' return;\n')
fd.write(' switch (simcall->call) {\n')
fd.write(' break;\n')
fd.write(' case SIMCALL_NONE:\n')
fd.write(' THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",\n')
- fd.write(' simcall->issuer->name.c_str(),\n')
- fd.write(' sg_host_get_name(simcall->issuer->host)\n')
+ fd.write(' simcall->issuer->get_cname(),\n')
+ fd.write(' sg_host_get_name(simcall->issuer->host_)\n')
fd.write(' );\n')
fd.write(' break;\n')
fd.write(' default:\n')
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name.c_str(),
+ XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(),
SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
SIMIX_process_yield(self);
} else {
#endif
/* Let's free maestro now */
- delete simix_global->maestro_process->context;
- simix_global->maestro_process->context = nullptr;
+ delete simix_global->maestro_process->context_;
+ simix_global->maestro_process->context_ = nullptr;
delete simix_global->maestro_process;
simix_global->maestro_process = nullptr;
if (boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro) != nullptr)
synchro_description = "I/O";
- XBT_INFO("Process %ld (%s@%s): waiting for %s synchro %p (%s) in state %d to finish", process->pid,
- process->get_cname(), process->host->get_cname(), synchro_description, process->waiting_synchro.get(),
+ XBT_INFO("Process %ld (%s@%s): waiting for %s synchro %p (%s) in state %d to finish", process->pid_,
+ process->get_cname(), process->host_->get_cname(), synchro_description, process->waiting_synchro.get(),
process->waiting_synchro->name_.c_str(), (int)process->waiting_synchro->state_);
}
else {
- XBT_INFO("Process %ld (%s@%s)", process->pid, process->get_cname(), process->host->get_cname());
+ XBT_INFO("Process %ld (%s@%s)", process->pid_, process->get_cname(), process->host_->get_cname());
}
}
}
if (arg->kill_time >= 0)
simcall_process_set_kill_time(actor, arg->kill_time);
if (arg->auto_restart)
- actor->auto_restart = arg->auto_restart;
+ actor->auto_restart_ = arg->auto_restart;
}
}
if (arg->kill_time >= 0)
simcall_process_set_kill_time(actor, arg->kill_time);
if (arg->auto_restart)
- actor->auto_restart = arg->auto_restart;
+ actor->auto_restart_ = arg->auto_restart;
}
process_list.clear();
}
break;
case SIMIX_FAILED:
- XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", simcall->issuer->host->get_cname());
- simcall->issuer->context->iwannadie = 1;
+ XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", simcall->issuer->host_->get_cname());
+ simcall->issuer->context_->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
break;
xbt_die("Internal error in SIMIX_execution_finish: unexpected synchro state %d", (int)exec->state_);
}
/* Fail the process if the host is down */
- if (simcall->issuer->host->is_off())
- simcall->issuer->context->iwannadie = 1;
+ if (simcall->issuer->host_->is_off())
+ simcall->issuer->context_->iwannadie = 1;
simcall->issuer->waiting_synchro = nullptr;
simcall_execution_wait__set__result(simcall, exec->state_);
xbt_die("Internal error in SIMIX_io_finish: unexpected synchro state %d", static_cast<int>(synchro->state_));
}
- if (simcall->issuer->host->is_off()) {
- simcall->issuer->context->iwannadie = 1;
+ if (simcall->issuer->host_->is_off()) {
+ simcall->issuer->context_->iwannadie = 1;
}
simcall->issuer->waiting_synchro = nullptr;
SIMIX_comm_finish(synchro);
} else { /* we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host
fails */
- simgrid::kernel::resource::Action* sleep = simcall->issuer->host->pimpl_cpu->sleep(timeout);
+ simgrid::kernel::resource::Action* sleep = simcall->issuer->host_->pimpl_cpu->sleep(timeout);
sleep->set_data(synchro.get());
simgrid::kernel::activity::CommImplPtr comm =
/* If both the sender and the receiver are already there, start the communication */
if (comm->state_ == SIMIX_READY) {
- simgrid::s4u::Host* sender = comm->src_proc->host;
- simgrid::s4u::Host* receiver = comm->dst_proc->host;
+ simgrid::s4u::Host* sender = comm->src_proc->host_;
+ simgrid::s4u::Host* receiver = comm->dst_proc->host_;
comm->surfAction_ = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
comm->surfAction_->set_data(comm.get());
/* If any of the process is suspended, create the synchro but stop its execution,
it will be restarted when the sender process resume */
- if (comm->src_proc->isSuspended() || comm->dst_proc->isSuspended()) {
- if (comm->src_proc->isSuspended())
+ if (comm->src_proc->is_suspended() || comm->dst_proc->is_suspended()) {
+ if (comm->src_proc->is_suspended())
XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the "
"communication",
- comm->src_proc->get_cname(), comm->src_proc->host->get_cname());
+ comm->src_proc->get_cname(), comm->src_proc->host_->get_cname());
else
XBT_DEBUG("The communication is suspended on startup because dst (%s@%s) was suspended since it initiated the "
"communication",
- comm->dst_proc->get_cname(), comm->dst_proc->host->get_cname());
+ comm->dst_proc->get_cname(), comm->dst_proc->host_->get_cname());
comm->surfAction_->suspend();
}
/* Check out for errors */
- if (simcall->issuer->host->is_off()) {
- simcall->issuer->context->iwannadie = 1;
+ if (simcall->issuer->host_->is_off()) {
+ simcall->issuer->context_->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
} else {
switch (comm->state_) {
case SIMIX_SRC_HOST_FAILURE:
if (simcall->issuer == comm->src_proc)
- simcall->issuer->context->iwannadie = 1;
+ simcall->issuer->context_->iwannadie = 1;
else
SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
break;
case SIMIX_DST_HOST_FAILURE:
if (simcall->issuer == comm->dst_proc)
- simcall->issuer->context->iwannadie = 1;
+ simcall->issuer->context_->iwannadie = 1;
else
SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
break;
case SIMIX_LINK_FAILURE:
XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) "
"detached:%d",
- synchro.get(), comm->src_proc ? comm->src_proc->host->get_cname() : nullptr,
- comm->dst_proc ? comm->dst_proc->host->get_cname() : nullptr, simcall->issuer->get_cname(),
+ synchro.get(), comm->src_proc ? comm->src_proc->host_->get_cname() : nullptr,
+ comm->dst_proc ? comm->dst_proc->host_->get_cname() : nullptr, simcall->issuer->get_cname(),
simcall->issuer, comm->detached);
if (comm->src_proc == simcall->issuer) {
XBT_DEBUG("I'm source");
}
}
- if (simcall->issuer->host->is_off()) {
- simcall->issuer->context->iwannadie = 1;
+ if (simcall->issuer->host_->is_off()) {
+ simcall->issuer->context_->iwannadie = 1;
}
simcall->issuer->waiting_synchro = nullptr;
return;
XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)", comm.get(),
- comm->src_proc ? comm->src_proc->host->get_cname() : "a finished process", comm->src_buff,
- comm->dst_proc ? comm->dst_proc->host->get_cname() : "a finished process", comm->dst_buff, buff_size);
+ comm->src_proc ? comm->src_proc->host_->get_cname() : "a finished process", comm->src_buff,
+ comm->dst_proc ? comm->dst_proc->host_->get_cname() : "a finished process", comm->dst_buff, buff_size);
/* Copy at most dst_buff_size bytes of the message to receiver's buffer */
if (comm->dst_buff_size)
if (synchro->state_ != SIMIX_SRC_TIMEOUT) {
if (synchro->state_ == SIMIX_FAILED)
- simcall->issuer->context->iwannadie = 1;
+ simcall->issuer->context_->iwannadie = 1;
else
THROW_IMPOSSIBLE;
}
XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
if (sem->value <= 0) {
- synchro = SIMIX_synchro_wait(issuer->host, timeout);
+ synchro = SIMIX_synchro_wait(issuer->host_, timeout);
synchro->simcalls_.push_front(simcall);
issuer->waiting_synchro = synchro;
sem->sleeping.push_back(*issuer);
ActorPtr me = Actor::self();
if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
return nullptr;
- simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->get_impl()->getUserData());
+ simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->get_impl()->get_user_data());
return static_cast<simgrid::smpi::Process*>(msgExt->data);
}
finalization_barrier_ = barrier;
actor_ = simgrid::s4u::Actor::self();
- static_cast<simgrid::msg::ActorExt*>(actor_->get_impl()->getUserData())->data = this;
+ static_cast<simgrid::msg::ActorExt*>(actor_->get_impl()->get_user_data())->data = this;
if (*argc > 3) {
memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2));
}
if (argc != nullptr && argv != nullptr) {
simgrid::s4u::ActorPtr proc = simgrid::s4u::Actor::self();
- proc->get_impl()->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
+ proc->get_impl()->context_->set_cleanup(&MSG_process_cleanup_from_SIMIX);
char* instance_id = (*argv)[1];
try {
int intra_comm_size = 0;
int min_index = INT_MAX; // the minimum index will be the leader
for (auto& actor : process_list) {
- int index = actor.pid;
+ int index = actor.pid_;
if (this->group()->rank(actor.iface()) != MPI_UNDEFINED) { // Is this process in the current group?
intra_comm_size++;
if (index < min_index)