smx_process_t next_work = (smx_process_t) xbt_parmap_next(raw_parmap);
RawContext* next_context = nullptr;
- if (next_work != NULL) {
+ if (next_work != nullptr) {
/* there is a next process to resume */
XBT_DEBUG("Run next process");
next_context = (RawContext*) next_work->context;
/* NOTE: The first argument to xbt_os_thread_create used to be the process *
* name, but now the name is stored at SIMIX level, so we pass a null */
this->thread_ =
- xbt_os_thread_create(NULL,
+ xbt_os_thread_create(nullptr,
maestro ? ThreadContext::maestro_wrapper : ThreadContext::wrapper,
this, this);
/* wait the starting of the newly created process */
// Signal to the maestro that it has finished:
xbt_os_sem_release(this->end_);
- xbt_os_thread_exit(NULL);
+ xbt_os_thread_exit(nullptr);
}
void ThreadContext::suspend()
this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
simgrid_makecontext(&this->uc_, smx_ctx_sysv_wrapper, this);
} else {
- if (process != NULL && sysv_maestro_context == NULL)
+ if (process != nullptr && sysv_maestro_context == nullptr)
sysv_maestro_context = this;
}
// Will contain the next soul to run, either simulated or initial minion's one
ucontext_t* next_stack;
- if (next_work != NULL) {
+ if (next_work != nullptr) {
// There is a next soul to embody (ie, a next process to resume)
XBT_DEBUG("Run next process");
next_context = (ParallelUContext*) next_work->context;
simgrid::simix::Comm::Comm(e_smx_comm_type_t _type) {
state = SIMIX_WAITING;
this->type = _type;
- src_data=NULL;
- dst_data=NULL;
+ src_data=nullptr;
+ dst_data=nullptr;
XBT_DEBUG("Create communicate synchro %p", this);
}
* we have to free the buffer */
if (clean_fun)
clean_fun(src_buff);
- src_buff = NULL;
+ src_buff = nullptr;
}
if(mbox)
{
if (surf_comm){
surf_comm->unref();
- surf_comm = NULL;
+ surf_comm = nullptr;
}
if (src_timeout){
src_timeout->unref();
- src_timeout = NULL;
+ src_timeout = nullptr;
}
if (dst_timeout){
dst_timeout->unref();
- dst_timeout = NULL;
+ dst_timeout = nullptr;
}
}
if (surf_exec) {
surf_exec->unref();
- surf_exec = NULL;
+ surf_exec = nullptr;
}
/* If there are simcalls associated with the synchro, then answer them */
simcall->issuer->context->iwannadie = 1;
}
simcall_process_sleep__set__result(simcall, state);
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
if (simcall->issuer->suspended) {
XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
simcall->issuer->suspended = 0;
/* checking for infinite values */
for (i = 0 ; i < host_nb ; ++i) {
xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
- if (bytes_amount != NULL) {
+ if (bytes_amount != nullptr) {
for (j = 0 ; j < host_nb ; ++j) {
xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
"bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
*
* The structure and the corresponding thread are created and put in the list of ready processes.
*
- * \param name a name for the process. It is for user-level information and can be NULL.
+ * \param name a name for the process. It is for user-level information and can be nullptr.
* \param code the main function of the process
- * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
+ * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be nullptr.
* It can be retrieved with the function \ref simcall_process_get_data.
* \param hostname name of the host where the new agent is executed.
* \param kill_time time when the process is killed
kill_time, process->name.c_str(), sg_host_get_name(process->host));
process->kill_timer = SIMIX_timer_set(kill_time, [=] {
simix_global->kill_process_function(process);
- process->kill_timer=NULL;
+ process->kill_timer=nullptr;
});
}
/**
* \ingroup simix_mbox_management
* \brief returns the communication at the head of the rendez-vous
* \param mbox The rendez-vous point
- * \return The communication or NULL if empty
+ * \return The communication or nullptr if empty
*/
smx_synchro_t simcall_mbox_front(smx_mailbox_t mbox)
{
if (MC_is_active() || MC_record_replay_is_active()) {
/* the model-checker wants two separate simcalls */
- smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
+ smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
comm = simcall_comm_isend(sender, mbox, task_size, rate,
- src_buff, src_buff_size, match_fun, NULL, copy_data_fun, data, 0);
+ src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
simcall_comm_wait(comm, timeout);
- comm = NULL;
+ comm = nullptr;
}
else {
simcall_BODY_comm_send(sender, mbox, task_size, rate, src_buff, src_buff_size,
if (MC_is_active() || MC_record_replay_is_active()) {
/* the model-checker wants two separate simcalls */
- smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
+ smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
match_fun, copy_data_fun, data, rate);
simcall_comm_wait(comm, timeout);
- comm = NULL;
+ comm = nullptr;
}
else {
simcall_BODY_comm_recv(receiver, mbox, dst_buff, dst_buff_size,
*/
void simcall_set_category(smx_synchro_t synchro, const char *category)
{
- if (category == NULL) {
+ if (category == nullptr) {
return;
}
simcall_BODY_set_category(synchro, category);
void SIMIX_function_register(const char *name, xbt_main_func_t code)
{
xbt_assert(simix_global, "SIMIX_global_init has to be called before SIMIX_function_register.");
- xbt_dict_set(simix_global->registered_functions, name, (void*) code, NULL);
+ xbt_dict_set(simix_global->registered_functions, name, (void*) code, nullptr);
}
-static xbt_main_func_t default_function = NULL;
+static xbt_main_func_t default_function = nullptr;
/**
* \brief Registers a #xbt_main_func_t code as default value.
*
/**
* \brief Gets a #smx_process_t code from the global table.
*
- * Gets a code function from the global table. Returns NULL if there are no function registered with the name.
+ * Gets a code function from the global table. Returns nullptr if there are no function registered with the name.
* This table is then used by #SIMIX_launch_application.
* \param name the reference name of the function.
- * \return The #smx_process_t or NULL.
+ * \return The #smx_process_t or nullptr.
*/
xbt_main_func_t SIMIX_get_registered_function(const char *name)
{
- xbt_main_func_t res = NULL;
+ xbt_main_func_t res = nullptr;
xbt_assert(simix_global,
"SIMIX_global_init has to be called before SIMIX_get_registered_function.");
xbt_dynar_foreach(arguments, i, arg) {
process.argv[i + 1] = xbt_strdup(arg);
}
- process.argv[process.argc] = NULL;
+ process.argv[process.argc] = nullptr;
xbt_main_func_t parse_code = SIMIX_get_registered_function(process_function);
xbt_assert(parse_code, "Function '%s' unknown", process_function);
XBT_LOG_NEW_CATEGORY(simix, "All SIMIX categories");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)");
-smx_global_t simix_global = NULL;
-static xbt_heap_t simix_timers = NULL;
+smx_global_t simix_global = nullptr;
+static xbt_heap_t simix_timers = nullptr;
/** @brief Timer datatype */
typedef struct s_smx_timer {
: date(date), callback(std::move(callback)) {}
} s_smx_timer_t;
-void (*SMPI_switch_data_segment)(int) = NULL;
+void (*SMPI_switch_data_segment)(int) = nullptr;
int _sg_do_verbose_exit = 1;
static void inthandler(int ignored)
if (!(old_stack.ss_flags & SS_DISABLE)) {
XBT_DEBUG("An alternate stack was already installed (sp=%p, size=%zd, flags=%x). Restore it.",
old_stack.ss_sp, old_stack.ss_size, old_stack.ss_flags);
- sigaltstack(&old_stack, NULL);
+ sigaltstack(&old_stack, nullptr);
}
struct sigaction action, old_action;
XBT_DEBUG("A signal handler was already installed for SIGSEGV (%p). Restore it.",
(old_action.sa_flags & SA_SIGINFO) ?
(void*)old_action.sa_sigaction : (void*)old_action.sa_handler);
- sigaction(SIGSEGV, &old_action, NULL);
+ sigaction(SIGSEGV, &old_action, nullptr);
}
}
static void kill_process(smx_process_t process)
{
- SIMIX_process_kill(process, NULL);
+ SIMIX_process_kill(process, nullptr);
}
static std::function<void()> maestro_code;
simix_global = xbt_new0(s_smx_global_t, 1);
simgrid::simix::Process proc;
- simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
- simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
+ simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), nullptr);
+ simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), nullptr);
simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc, process_hookup));
simix_global->process_to_destroy = xbt_swag_new(xbt_swag_offset(proc, destroy_hookup));
- simix_global->maestro_process = NULL;
- simix_global->registered_functions = xbt_dict_new_homogeneous(NULL);
+ simix_global->maestro_process = nullptr;
+ simix_global->registered_functions = xbt_dict_new_homogeneous(nullptr);
simix_global->create_process_function = &SIMIX_process_create;
simix_global->kill_process_function = &kill_process;
const char* name = storage->getName();
// TODO, create sg_storage_by_name
sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, name);
- xbt_assert(s != NULL, "Storage not found for name %s", name);
+ xbt_assert(s != nullptr, "Storage not found for name %s", name);
- SIMIX_storage_create(name, s, NULL);
+ SIMIX_storage_create(name, s, nullptr);
});
SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
SIMIX_mailbox_exit();
xbt_heap_free(simix_timers);
- simix_timers = NULL;
+ simix_timers = nullptr;
/* Free the remaining data structures */
xbt_dynar_free(&simix_global->process_to_run);
xbt_dynar_free(&simix_global->process_that_ran);
xbt_swag_free(simix_global->process_to_destroy);
xbt_swag_free(simix_global->process_list);
- simix_global->process_list = NULL;
- simix_global->process_to_destroy = NULL;
+ simix_global->process_list = nullptr;
+ simix_global->process_to_destroy = nullptr;
xbt_dict_free(&(simix_global->registered_functions));
xbt_os_mutex_destroy(simix_global->mutex);
- simix_global->mutex = NULL;
+ simix_global->mutex = nullptr;
/* Let's free maestro now */
delete simix_global->maestro_process->context;
xbt_free(simix_global->maestro_process->running_ctx);
simix_global->maestro_process->running_ctx = nullptr;
delete simix_global->maestro_process;
- simix_global->maestro_process = NULL;
+ simix_global->maestro_process = nullptr;
/* Restore the default exception setup */
__xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
surf_exit();
xbt_free(simix_global);
- simix_global = NULL;
+ simix_global = nullptr;
return;
}
XBT_DEBUG("Handling process whose action terminated normally");
while ((action = surf_model_extract_done_action_set(model))) {
XBT_DEBUG(" Handling Action %p",action);
- if (action->getData() == NULL)
+ if (action->getData() == nullptr)
XBT_DEBUG("probably vcpu's action %p, skip", action);
else
SIMIX_simcall_exit((smx_synchro_t) action->getData());
XBT_DEBUG("Handling process whose action terminated normally");
while ((action = surf_model_extract_done_action_set(model))) {
XBT_DEBUG(" Handling Action %p",action);
- if (action->getData() == NULL)
+ if (action->getData() == nullptr)
XBT_DEBUG("probably vcpu's action %p, skip", action);
else
SIMIX_simcall_exit((smx_synchro_t) action->getData());
}
/* Autorestart all process */
- char *hostname = NULL;
+ char *hostname = nullptr;
xbt_dynar_foreach(host_that_restart,iter,hostname) {
XBT_INFO("Restart processes on host: %s",hostname);
SIMIX_host_autorestart(sg_host_by_name(hostname));
xbt_heap_rm_elm(simix_timers, timer, timer->date);
}
-/** @brief Returns the date at which the timer will trigger (or 0 if NULL timer) */
+/** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */
double SIMIX_timer_get_date(smx_timer_t timer) {
return timer?timer->date:0;
}
void SIMIX_display_process_status(void)
{
- if (simix_global->process_list == NULL) {
+ if (simix_global->process_list == nullptr) {
return;
}
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
int nbprocess = xbt_swag_size(simix_global->process_list);
XBT_INFO("%d processes are still running, waiting for something.", nbprocess);
int SIMIX_is_maestro()
{
- return simix_global==NULL /*SimDag*/|| SIMIX_process_self() == simix_global->maestro_process;
+ return simix_global==nullptr /*SimDag*/|| SIMIX_process_self() == simix_global->maestro_process;
}
{
smx_host_priv_t host = sg_host_simix(h);
- xbt_assert((host != NULL), "Invalid parameters");
+ xbt_assert((host != nullptr), "Invalid parameters");
if (h->isOff()) {
simgrid::surf::HostImpl* surf_host = h->extension<simgrid::surf::HostImpl>();
if (simix_global->create_process_function) {
simix_global->create_process_function(arg->name.c_str(),
arg->code,
- NULL,
+ nullptr,
arg->hostname,
arg->kill_time,
arg->properties,
arg->auto_restart,
- NULL);
+ nullptr);
} else {
simcall_process_create(arg->name.c_str(),
arg->code,
- NULL,
+ nullptr,
arg->hostname,
arg->kill_time,
arg->properties,
{
smx_host_priv_t host = sg_host_simix(h);
- xbt_assert((host != NULL), "Invalid parameters");
+ xbt_assert((host != nullptr), "Invalid parameters");
if (h->isOn()) {
simgrid::surf::HostImpl* surf_host = h->extension<simgrid::surf::HostImpl>();
/* Clean Simulator data */
if (xbt_swag_size(host->process_list) != 0) {
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
xbt_swag_foreach(process, host->process_list) {
SIMIX_process_kill(process, issuer);
XBT_DEBUG("Killing %s on %s by %s",
{
smx_host_priv_t host = (smx_host_priv_t) h;
- xbt_assert((host != NULL), "Invalid parameters");
+ xbt_assert((host != nullptr), "Invalid parameters");
/* Clean Simulator data */
if (xbt_swag_size(host->process_list) != 0) {
char *msg = xbt_strdup("Shutting down host, but it's not empty:");
char *tmp;
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
xbt_swag_foreach(process, host->process_list) {
tmp = bprintf("%s\n\t%s", msg, process->name.c_str());
sg_host_t SIMIX_host_self(void)
{
smx_process_t process = SIMIX_process_self();
- return (process == NULL) ? NULL : SIMIX_process_get_host(process);
+ return (process == nullptr) ? nullptr : SIMIX_process_get_host(process);
}
/* needs to be public and without simcall for exceptions and logging events */
const char* SIMIX_host_self_get_name(void)
{
sg_host_t host = SIMIX_host_self();
- if (host == NULL || SIMIX_process_self() == simix_global->maestro_process)
+ if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
return "";
return sg_host_get_name(host);
arg->auto_restart = auto_restart;
if( host->isOff() && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_get_name(host))){
- xbt_dict_set(watched_hosts_lib,sg_host_get_name(host),host,NULL);
+ xbt_dict_set(watched_hosts_lib,sg_host_get_name(host),host,nullptr);
XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_get_name(host));
}
xbt_dynar_push_as(sg_host_simix(host)->auto_restart_processes,smx_process_arg_t,arg);
if (simix_global->create_process_function) {
simix_global->create_process_function(arg->name.c_str(),
arg->code,
- NULL,
+ nullptr,
arg->hostname,
arg->kill_time,
arg->properties,
arg->auto_restart,
- NULL);
+ nullptr);
} else {
simcall_process_create(arg->name.c_str(),
arg->code,
- NULL,
+ nullptr,
arg->hostname,
arg->kill_time,
arg->properties,
double *flops_amount, double *bytes_amount,
double amount, double rate){
- sg_host_t *host_list_cpy = NULL;
+ sg_host_t *host_list_cpy = nullptr;
int i;
/* alloc structures and initialize */
if (simcall->issuer->host->isOff())
simcall->issuer->context->iwannadie = 1;
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
simcall_execution_wait__set__result(simcall, exec->state);
SIMIX_simcall_answer(simcall);
}
* \brief Internal function to create a SIMIX storage.
* \param name name of the storage to create
* \param storage the SURF storage to encapsulate
- * \param data some user data (may be NULL)
+ * \param data some user data (may be nullptr)
*/
smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
{
{
smx_storage_priv_t storage = (smx_storage_priv_t) s;
- xbt_assert((storage != NULL), "Invalid parameters");
+ xbt_assert((storage != nullptr), "Invalid parameters");
if (storage->data)
free(storage->data);
simcall->issuer->context->iwannadie = 1;
}
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
SIMIX_simcall_answer(simcall);
}
mbox->name = xbt_strdup(name);
mbox->comm_queue = new std::deque<smx_synchro_t>();
mbox->done_comm_queue = nullptr; // Allocated on need only
- mbox->permanent_receiver=NULL;
+ mbox->permanent_receiver=nullptr;
XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
- xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
+ xbt_dict_set(mailboxes, mbox->name, mbox, nullptr);
}
return mbox;
}
{
simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
- comm->mbox = NULL;
+ comm->mbox = nullptr;
for (auto it = mbox->comm_queue->begin(); it != mbox->comm_queue->end(); it++)
if (*it == comm) {
mbox->comm_queue->erase(it);
/**
* \brief Checks if there is a communication synchro queued in a deque matching our needs
* \param type The type of communication we are looking for (comm_send, comm_recv)
- * \return The communication synchro if found, NULL otherwise
+ * \return The communication synchro if found, nullptr otherwise
*/
static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
int (*match_fun)(void *, void *,smx_synchro_t), void *this_user_data, smx_synchro_t my_synchro, bool remove_matching)
{
- void* other_user_data = NULL;
+ void* other_user_data = nullptr;
for(auto it = deque->begin(); it != deque->end(); it++){
smx_synchro_t synchro = *it;
#if HAVE_MC
comm->mbox_cpy = comm->mbox;
#endif
- comm->mbox = NULL;
+ comm->mbox = nullptr;
return comm;
}
XBT_DEBUG("Sorry, communication synchro %p does not match our needs:"
comm, (int)comm->type, (int)type);
}
XBT_DEBUG("No matching communication synchro found");
- return NULL;
+ return nullptr;
}
/******************************************************************************/
void (*copy_data_fun)(smx_synchro_t, void*, size_t),
void *data, double timeout){
smx_synchro_t comm = simcall_HANDLER_comm_isend(simcall, src, mbox, task_size, rate,
- src_buff, src_buff_size, match_fun, NULL, copy_data_fun,
+ src_buff, src_buff_size, match_fun, nullptr, copy_data_fun,
data, 0);
SIMCALL_SET_MC_VALUE(simcall, 0);
simcall_HANDLER_comm_wait(simcall, comm, timeout);
other_synchro = this_synchro;
other_comm = static_cast<simgrid::simix::Comm*>(other_synchro);
- if (mbox->permanent_receiver!=NULL){
+ if (mbox->permanent_receiver!=nullptr){
//this mailbox is for small messages, which have to be sent right now
other_synchro->state = SIMIX_READY;
other_comm->dst_proc=mbox->permanent_receiver;
other_comm->detached = true;
other_comm->clean_fun = clean_fun;
} else {
- other_comm->clean_fun = NULL;
+ other_comm->clean_fun = nullptr;
}
/* Setup the communication synchro */
if (MC_is_active() || MC_record_replay_is_active()) {
other_comm->state = SIMIX_RUNNING;
- return (detached ? NULL : other_comm);
+ return (detached ? nullptr : other_comm);
}
SIMIX_comm_start(other_comm);
- return (detached ? NULL : other_comm);
+ return (detached ? nullptr : other_comm);
}
XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox,
XBT_DEBUG("comm %p has been already sent, and is finished, destroy it",other_comm);
other_comm->state = SIMIX_DONE;
other_comm->type = SIMIX_COMM_DONE;
- other_comm->mbox = NULL;
+ other_comm->mbox = nullptr;
}
other_comm->unref();
static_cast<simgrid::simix::Comm*>(this_synchro)->unref();
this_comm = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE);
smx_type = SIMIX_COMM_SEND;
}
- smx_synchro_t other_synchro=NULL;
+ smx_synchro_t other_synchro=nullptr;
if(mbox->permanent_receiver && ! mbox->done_comm_queue->empty()){
XBT_DEBUG("first check in the permanent recv mailbox, to see if we already got something");
other_synchro =
XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
synchro,
- comm->src_proc ? sg_host_get_name(comm->src_proc->host) : NULL,
- comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : NULL,
+ comm->src_proc ? sg_host_get_name(comm->src_proc->host) : nullptr,
+ comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : nullptr,
simcall->issuer->name.c_str(), simcall->issuer, comm->detached);
if (comm->src_proc == simcall->issuer) {
XBT_DEBUG("I'm source");
simcall->issuer->context->iwannadie = 1;
}
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
xbt_fifo_remove(simcall->issuer->comms, synchro);
if(comm->detached){
if(simcall->issuer == comm->src_proc){
memcpy(comm->dst_buff, buff, buff_size);
if (comm->detached) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the original buffer available to the application ASAP
xbt_free(buff);
- comm->src_buff = NULL;
+ comm->src_buff = nullptr;
}
}
{
smx_context_t self_context = SIMIX_context_self();
- return self_context ? self_context->process() : NULL;
+ return self_context ? self_context->process() : nullptr;
}
/**
SIMIX_process_on_exit_runall(process);
/* Unregister from the kill timer if any */
- if (process->kill_timer != NULL)
+ if (process->kill_timer != nullptr)
SIMIX_timer_remove(process->kill_timer);
xbt_os_mutex_acquire(simix_global->mutex);
if (comm->src_proc == process) {
XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
comm, comm->detached, (int)comm->state, comm->src_proc, comm->dst_proc);
- comm->src_proc = NULL;
+ comm->src_proc = nullptr;
/* I'm not supposed to destroy a detached comm from the sender side, */
if (comm->detached)
else if (comm->dst_proc == process){
XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
comm, (int)comm->state, comm->src_proc, comm->dst_proc);
- comm->dst_proc = NULL;
+ comm->dst_proc = nullptr;
- if (comm->detached && comm->src_proc != NULL) {
+ if (comm->detached && comm->src_proc != nullptr) {
/* the comm will be freed right now, remove it from the sender */
xbt_fifo_remove(comm->src_proc->comms, comm);
}
*/
void SIMIX_process_empty_trash(void)
{
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
while ((process = (smx_process_t) xbt_swag_extract(simix_global->process_to_destroy))) {
XBT_DEBUG("Getting rid of %p",process);
void create_maestro(std::function<void()> code)
{
- smx_process_t maestro = NULL;
+ smx_process_t maestro = nullptr;
/* Create maestro process and intilialize it */
maestro = new simgrid::simix::Process();
maestro->pid = simix_process_maxpid++;
XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
if (!code) {
- maestro->context = SIMIX_context_new(std::function<void()>(), NULL, maestro);
+ maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
} else {
if (!simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
int auto_restart,
smx_process_t parent_process)
{
- smx_process_t process = NULL;
+ smx_process_t process = nullptr;
sg_host_t host = sg_host_by_name(hostname);
XBT_DEBUG("Start process %s on host '%s'", name, hostname);
else {
process = new simgrid::simix::Process();
- xbt_assert(code && host != NULL, "Invalid parameters");
+ xbt_assert(code && host != nullptr, "Invalid parameters");
/* Process data */
process->pid = simix_process_maxpid++;
process->name = simgrid::xbt::string(name);
/* Initiliaze data segment to default value */
SIMIX_segment_index_set(process, -1);
- if (parent_process != NULL) {
+ if (parent_process != nullptr) {
process->ppid = SIMIX_process_get_PID(parent_process);
/* SMPI process have their own data segment and
each other inherit from their father */
process->ppid = -1;
/* Initiliaze data segment to default value */
SIMIX_segment_index_set(process, -1);
- if (parent_process != NULL) {
+ if (parent_process != nullptr) {
process->ppid = SIMIX_process_get_PID(parent_process);
/* SMPI process have their own data segment and
each other inherit from their father */
break;
} */
- process->waiting_synchro = NULL;
+ process->waiting_synchro = nullptr;
}
if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) {
XBT_DEBUG("Inserting %s in the to_run list", process->name.c_str());
SIMIX_io_destroy(process->waiting_synchro);
}
}
- process->waiting_synchro = NULL;
+ process->waiting_synchro = nullptr;
}
*/
void SIMIX_process_killall(smx_process_t issuer, int reset_pid)
{
- smx_process_t p = NULL;
+ smx_process_t p = nullptr;
while ((p = (smx_process_t) xbt_swag_extract(simix_global->process_list))) {
if (p != issuer) {
void SIMIX_process_change_host(smx_process_t process,
sg_host_t dest)
{
- xbt_assert((process != NULL), "Invalid parameters");
+ xbt_assert((process != nullptr), "Invalid parameters");
xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
process->host = dest;
xbt_swag_insert(process, sg_host_simix(dest)->process_list);
{
if (process->suspended) {
XBT_DEBUG("Process '%s' is already suspended", process->name.c_str());
- return NULL;
+ return nullptr;
}
process->suspended = 1;
process->waiting_synchro->suspend();
/* If the other process is not waiting, its suspension is delayed to when the process is rescheduled. */
- return NULL;
+ return nullptr;
} else {
/* FIXME: computation size is zero. Is it okay that bound is zero ? */
return SIMIX_execution_start(process, "suspend", 0.0, 1.0, 0.0, 0);
}
int SIMIX_process_get_PID(smx_process_t self){
- if (self == NULL)
+ if (self == nullptr)
return 0;
else
return self->pid;
}
int SIMIX_process_get_PPID(smx_process_t self){
- if (self == NULL)
+ if (self == nullptr)
return 0;
else
return self->ppid;
smx_process_t self = SIMIX_process_self();
if (!self) {
- return NULL;
+ return nullptr;
}
return SIMIX_process_get_data(self);
}
const char* SIMIX_process_self_get_name(void) {
smx_process_t process = SIMIX_process_self();
- if (process == NULL || process == simix_global->maestro_process)
+ if (process == nullptr || process == simix_global->maestro_process)
return "maestro";
return SIMIX_process_get_name(process);
if (proc->name == name)
return proc;
}
- return NULL;
+ return nullptr;
}
int SIMIX_process_is_suspended(smx_process_t process)
smx_simcall_t simcall = sleep->simcalls.front();
sleep->simcalls.pop_front();
simcall_process_sleep__set__result(simcall, SIMIX_DONE);
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
if (simcall->issuer->suspended) {
XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
simcall->issuer->suspended = 0;
}
}
sleep->surf_sleep->unref();
- sleep->surf_sleep = NULL;
+ sleep->surf_sleep = nullptr;
}
delete sleep;
return 0;
if (sleep->surf_sleep) {
sleep->surf_sleep->unref();
- sleep->surf_sleep = NULL;
+ sleep->surf_sleep = nullptr;
}
}
if (self->new_host) {
SIMIX_process_change_host(self, self->new_host);
- self->new_host = NULL;
+ self->new_host = nullptr;
}
if (self->context->iwannadie){
if (proc->pid == (unsigned long) PID)
return proc;
}
- return NULL;
+ return nullptr;
}
/** @brief returns a dynar containg all currently existing processes */
xbt_dynar_t SIMIX_processes_as_dynar(void) {
smx_process_t proc;
- xbt_dynar_t res = xbt_dynar_new(sizeof(smx_process_t),NULL);
+ xbt_dynar_t res = xbt_dynar_new(sizeof(smx_process_t),nullptr);
xbt_swag_foreach(proc, simix_global->process_list) {
xbt_dynar_push(res,&proc);
}
xbt_assert(process, "current process not found: are you in maestro context ?");
if (!process->on_exit) {
- process->on_exit = xbt_dynar_new(sizeof(s_smx_process_exit_fun_t), NULL);
+ process->on_exit = xbt_dynar_new(sizeof(s_smx_process_exit_fun_t), nullptr);
}
s_smx_process_exit_fun_t exit_fun = {fun, data};
arg.hostname = sg_host_get_name(process->host);
arg.kill_time = SIMIX_timer_get_date(process->kill_timer);
arg.data = process->data;
- arg.properties = NULL;
+ arg.properties = nullptr;
arg.auto_restart = process->auto_restart;
//kill the old process
}
SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
- simcall->issuer->waiting_synchro = NULL;
+ simcall->issuer->waiting_synchro = nullptr;
delete synchro;
SIMIX_simcall_answer(simcall);
XBT_OUT();
{
XBT_IN("(%p)",simcall);
/* FIXME: check where to validate the arguments */
- smx_synchro_t synchro = NULL;
+ smx_synchro_t synchro = nullptr;
smx_process_t process = simcall->issuer;
if (mutex->locked) {
/*process to wake up */
smx_process_t p = (smx_process_t) xbt_swag_extract(mutex->sleeping);
delete p->waiting_synchro;
- p->waiting_synchro = NULL;
+ p->waiting_synchro = nullptr;
mutex->owner = p;
SIMIX_simcall_answer(&p->simcall);
} else {
/* nobody to wake up */
mutex->locked = 0;
- mutex->owner = NULL;
+ mutex->owner = nullptr;
}
XBT_OUT();
}
simgrid::simix::Process p;
smx_cond_t cond = xbt_new0(s_smx_cond_t, 1);
cond->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));
- cond->mutex = NULL;
+ cond->mutex = nullptr;
XBT_OUT();
return cond;
}
smx_process_t issuer, smx_simcall_t simcall)
{
XBT_IN("(%p, %p, %f, %p,%p)",cond,mutex,timeout,issuer,simcall);
- smx_synchro_t synchro = NULL;
+ smx_synchro_t synchro = nullptr;
XBT_DEBUG("Wait condition %p", cond);
/* If there is a mutex unlock it */
/* FIXME: what happens if the issuer is not the owner of the mutex? */
- if (mutex != NULL) {
+ if (mutex != nullptr) {
cond->mutex = mutex;
SIMIX_mutex_unlock(mutex, issuer);
}
void SIMIX_cond_signal(smx_cond_t cond)
{
XBT_IN("(%p)",cond);
- smx_process_t proc = NULL;
- smx_mutex_t mutex = NULL;
- smx_simcall_t simcall = NULL;
+ smx_process_t proc = nullptr;
+ smx_mutex_t mutex = nullptr;
+ smx_simcall_t simcall = nullptr;
XBT_DEBUG("Signal condition %p", cond);
/* Destroy waiter's synchronization */
delete proc->waiting_synchro;
- proc->waiting_synchro = NULL;
+ proc->waiting_synchro = nullptr;
/* Now transform the cond wait simcall into a mutex lock one */
simcall = &proc->simcall;
XBT_IN("(%p)",cond);
XBT_DEBUG("Destroy condition %p", cond);
- if (cond != NULL) {
+ if (cond != nullptr) {
xbt_assert(xbt_swag_size(cond->sleeping) == 0,
"Cannot destroy conditional since someone is still using it");
{
XBT_IN("(%p)",sem);
XBT_DEBUG("Destroy semaphore %p", sem);
- if (sem != NULL) {
+ if (sem != nullptr) {
xbt_assert(xbt_swag_size(sem->sleeping) == 0,
"Cannot destroy semaphore since someone is still using it");
xbt_swag_free(sem->sleeping);
XBT_DEBUG("Sem release semaphore %p", sem);
if ((proc = (smx_process_t) xbt_swag_extract(sem->sleeping))) {
delete proc->waiting_synchro;
- proc->waiting_synchro = NULL;
+ proc->waiting_synchro = nullptr;
SIMIX_simcall_answer(&proc->simcall);
} else if (sem->value < SMX_SEM_NOLIMIT) {
sem->value++;
smx_simcall_t simcall)
{
XBT_IN("(%p, %f, %p, %p)",sem,timeout,issuer,simcall);
- smx_synchro_t synchro = NULL;
+ smx_synchro_t synchro = nullptr;
XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
if (sem->value <= 0) {
/**
* @brief Internal function to create a SIMIX host.
* @param name name of the host to create
- * @param data some user data (may be NULL)
+ * @param data some user data (may be nullptr)
*/
sg_host_t SIMIX_vm_create(const char *name, sg_host_t ind_phys_host)
{
int pm_overcommit = 0;
long pm_ramsize = host_get_ramsize(pm, &pm_overcommit);
- long vm_ramsize = host_get_ramsize(vm, NULL);
+ long vm_ramsize = host_get_ramsize(vm, nullptr);
if (!pm_ramsize) {
/* We assume users do not want to care about ramsize. */
unsigned int cursor = 0;
sg_host_t another_vm;
xbt_dynar_foreach(dyn_vms, cursor, another_vm) {
- long another_vm_ramsize = host_get_ramsize(vm, NULL);
+ long another_vm_ramsize = host_get_ramsize(vm, nullptr);
total_ramsize_of_vms += another_vm_ramsize;
}
}