X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8d51848cefcf39dbe0072eacd5fc50765b8b4e37..026c5a576fbea1da8f6290f4435d5424ce0efe8b:/src/simix/smx_global.cpp diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 0d7299f706..cb24df2b63 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2019. 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. */ @@ -144,12 +144,6 @@ double SIMIX_timer_next() return simix_timers.empty() ? -1.0 : simix_timers.top().first; } -static void kill_process(smx_actor_t process) -{ - SIMIX_process_kill(process, nullptr); -} - - namespace simgrid { namespace simix { @@ -168,8 +162,8 @@ void SIMIX_set_maestro(void (*code)(void*), void* data) } /** - * \ingroup SIMIX_API - * \brief Initialize SIMIX internal data. + * @ingroup SIMIX_API + * @brief Initialize SIMIX internal data. */ void SIMIX_global_init(int *argc, char **argv) { @@ -179,13 +173,9 @@ void SIMIX_global_init(int *argc, char **argv) simgrid::mc::Client::initialize(); #endif - if (not simix_global) { + if (simix_global == nullptr) { simix_global = std::unique_ptr(new simgrid::simix::Global()); simix_global->maestro_process = nullptr; - simix_global->create_process_function = &SIMIX_process_create; - simix_global->kill_process_function = &kill_process; - simix_global->cleanup_process_function = &SIMIX_process_cleanup; - simix_global->mutex = xbt_os_mutex_init(); surf_init(argc, argv); /* Initialize SURF structures */ SIMIX_context_mod_init(); @@ -202,10 +192,10 @@ void SIMIX_global_init(int *argc, char **argv) #endif /* register a function to be called by SURF after the environment creation */ sg_platf_init(); - simgrid::s4u::on_platform_created.connect(SIMIX_post_create_environment); + simgrid::s4u::on_platform_created.connect(surf_presolve); simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage& storage) { - sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_cname()); + sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_name()); xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname()); }); } @@ -219,8 +209,8 @@ void SIMIX_global_init(int *argc, char **argv) int smx_cleaned = 0; /** - * \ingroup SIMIX_API - * \brief Clean the SIMIX simulation + * @ingroup SIMIX_API + * @brief Clean the SIMIX simulation * * This functions remove the memory used by SIMIX */ @@ -250,7 +240,7 @@ void SIMIX_clean() #endif /* Kill all processes (but maestro) */ - SIMIX_process_killall(simix_global->maestro_process); + simix_global->maestro_process->kill_all(); SIMIX_context_runall(); SIMIX_process_empty_trash(); @@ -267,8 +257,6 @@ void SIMIX_clean() simix_global->process_to_destroy.clear(); simix_global->process_list.clear(); - xbt_os_mutex_destroy(simix_global->mutex); - simix_global->mutex = nullptr; #if SIMGRID_HAVE_MC xbt_dynar_free(&simix_global->actors_vector); xbt_dynar_free(&simix_global->dead_actors_vector); @@ -288,12 +276,11 @@ void SIMIX_clean() simix_global = nullptr; } - /** - * \ingroup SIMIX_API - * \brief A clock (in second). + * @ingroup SIMIX_API + * @brief A clock (in second). * - * \return Return the clock. + * @return Return the clock. */ double SIMIX_get_clock() { @@ -373,8 +360,8 @@ static bool SIMIX_execute_tasks() } /** - * \ingroup SIMIX_API - * \brief Run the main simulation loop. + * @ingroup SIMIX_API + * @brief Run the main simulation loop. */ void SIMIX_run() { @@ -483,7 +470,7 @@ void SIMIX_run() if (simix_global->process_list.size() == simix_global->daemons.size()) for (auto const& dmon : simix_global->daemons) { XBT_DEBUG("Kill %s", dmon->get_cname()); - SIMIX_process_kill(dmon, simix_global->maestro_process); + simix_global->maestro_process->kill(dmon); } } @@ -507,13 +494,6 @@ void SIMIX_run() SIMIX_wake_processes(); } while (again); - /* Autorestart all process */ - for (auto const& host : host_that_restart) { - XBT_INFO("Restart processes on host %s", host->get_cname()); - SIMIX_host_autorestart(host); - } - host_that_restart.clear(); - /* Clean processes to destroy */ SIMIX_process_empty_trash(); @@ -538,12 +518,12 @@ void SIMIX_run() } /** - * \brief Set the date to execute a function + * @brief Set the date to execute a function * * Set the date to execute the function on the surf. - * \param date Date to execute function - * \param callback Function to be executed - * \param arg Parameters of the function + * @param date Date to execute function + * @param callback Function to be executed + * @param arg Parameters of the function * */ smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void *arg) @@ -571,45 +551,6 @@ double SIMIX_timer_get_date(smx_timer_t timer) { return timer ? timer->getDate() : 0; } -/** - * \brief Registers a function to create a process. - * - * This function registers a function to be called - * when a new process is created. The function has - * to call SIMIX_process_create(). - * \param function create process function - */ -void SIMIX_function_register_process_create(smx_creation_func_t function) -{ - simix_global->create_process_function = function; -} - -/** - * \brief Registers a function to kill a process. - * - * This function registers a function to be called when a process is killed. The function has to call the - * SIMIX_process_kill(). - * - * \param function Kill process function - */ -void SIMIX_function_register_process_kill(void_pfn_smxprocess_t function) -{ - simix_global->kill_process_function = function; -} - -/** - * \brief Registers a function to cleanup a process. - * - * This function registers a user function to be called when a process ends properly. - * - * \param function cleanup process function - */ -void SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function) -{ - simix_global->cleanup_process_function = function; -} - - void SIMIX_display_process_status() { int nbprocess = simix_global->process_list.size(); @@ -641,7 +582,7 @@ void SIMIX_display_process_status() 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_); + process->waiting_synchro->get_cname(), (int)process->waiting_synchro->state_); } else { XBT_INFO("Process %ld (%s@%s)", process->pid_, process->get_cname(), process->host_->get_cname());