X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f85c01fa01dfbf9b06f6e8c1fa01e34f49647db..945f379f0d3d7f8e923ee114de2e492e1cb5486f:/src/simix/smx_host.c diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 8368560ab7..b260c3d791 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -10,20 +10,8 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -/** \defgroup m_host_management Management functions of Hosts - * \brief This section describes the host structure of MSG - * - * \htmlonly \endhtmlonly - * (#m_host_t) and the functions for managing it. - * - * A location (or host) is any possible place where - * a process may run. Thus it may be represented as a - * physical resource with computing capabilities, some - * mailboxes to enable running process to communicate with - * remote ones, and some private data that can be only - * accessed by local process. - * \see m_host_t - */ +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, + "Logging specific to SIMIX (hosts)"); /********************************* Host **************************************/ smx_host_t __SIMIX_host_create(const char *name, @@ -49,12 +37,13 @@ smx_host_t __SIMIX_host_create(const char *name, return host; } -/** \ingroup m_host_management +/** + * \brief Set the user data of a #smx_host_t. * - * \brief Set the user data of a #m_host_t. + * This functions checks whether some data has already been associated to \a host or not and attach \a data to \a host if it is possible. + * \param host SIMIX host + * \param data User data * - * This functions checks whether some data has already been associated to \a host - or not and attach \a data to \a host if it is possible. */ void SIMIX_host_set_data(smx_host_t host, void *data) { @@ -67,28 +56,25 @@ void SIMIX_host_set_data(smx_host_t host, void *data) return ; } -/** \ingroup m_host_management - * - * \brief Return the user data of a #m_host_t. +/** + * \brief Return the user data of a #smx_host_t. * - * This functions checks whether \a host is a valid pointer or not and return - the user data associated to \a host if it is possible. + * This functions checks whether \a host is a valid pointer or not and return the user data associated to \a host if it is possible. + * \param host SIMIX host */ void *SIMIX_host_get_data(smx_host_t host) { - xbt_assert0((host != NULL), "Invalid parameters"); /* Return data */ return (host->data); } -/** \ingroup m_host_management +/** + * \brief Return the name of the #smx_host_t. * - * \brief Return the name of the #m_host_t. - * - * This functions checks whether \a host is a valid pointer or not and return - its name. + * This functions checks whether \a host is a valid pointer or not and return its name. + * \param host SIMIX host */ const char *SIMIX_host_get_name(smx_host_t host) { @@ -99,9 +85,11 @@ const char *SIMIX_host_get_name(smx_host_t host) return (host->name); } -/** \ingroup m_host_management - * +/** * \brief Return the location on which the current process is executed. + * + * Return the host, more details in #SIMIX_process_get_host + * \return SIMIX host */ smx_host_t SIMIX_host_self(void) { @@ -123,8 +111,19 @@ void __SIMIX_host_destroy(smx_host_t host) /* Clean Simulator data */ simdata = host->simdata; - xbt_assert0((xbt_swag_size(simdata->process_list)==0), - "Some process are still running on this host"); + if (xbt_swag_size(simdata->process_list) != 0) { + char *msg=bprintf("Shutting down host %s, but it's not empty:", host->name); + char *tmp; + smx_process_t process = NULL; + + xbt_swag_foreach(process, simdata->process_list) { + tmp = bprintf("%s\n\t%s",msg,process->name); + free(msg); + msg=tmp; + } + THROW1(arg_error,0,"%s",msg); + } + xbt_swag_free(simdata->process_list); free(simdata); @@ -136,16 +135,20 @@ void __SIMIX_host_destroy(smx_host_t host) return; } -/** \ingroup m_host_management - * \brief Return the current number of #m_host_t. +/** + * \brief Return the current number of #smx_host_t. + * + * \return Number of hosts */ int SIMIX_host_get_number(void) { return (xbt_fifo_size(simix_global->host)); } -/** \ingroup m_host_management - * \brief Return a array of all the #m_host_t. +/** + * \brief Return a array of all the #smx_host_t. + * + * \return List of all hosts */ smx_host_t *SIMIX_host_get_table(void) { @@ -153,9 +156,12 @@ smx_host_t *SIMIX_host_get_table(void) } -/** \ingroup m_host_management - * \brief Return the speed of the processor (in Mflop/s), regardless of - the current load on the machine. +/** + * \brief Return the speed of the processor. + * + * Return the speed (in Mflop/s), regardless of the current load on the machine. + * \param host SIMIX host + * \return Speed */ double SIMIX_host_get_speed(smx_host_t host) { @@ -165,6 +171,12 @@ double SIMIX_host_get_speed(smx_host_t host) extension_public->get_speed(host->simdata->host,1.0)); } +/** + * \brief Return the available speed of the processor. + * + * Return the available speed (in Mflop/s). + * \return Speed + */ double SIMIX_host_get_available_speed(smx_host_t host) { xbt_assert0((host!= NULL), "Invalid parameters"); @@ -173,20 +185,13 @@ double SIMIX_host_get_available_speed(smx_host_t host) extension_public->get_available_speed(host->simdata->host)); } -/** \ingroup msg_gos_functions - * \brief Determine if a host is available. +/** + * \brief Return the host by its name * - * \param h host to test + * Finds a smx_host_t using its name. + * \param name The name of an host. + * \return The corresponding host */ - -/** \ingroup msg_easier_life - * \brief A name directory service... - * - * Finds a m_host_t using its name. - * \param name the name of an host. - * \return the corresponding host - */ - smx_host_t SIMIX_host_get_by_name(const char *name) { xbt_fifo_item_t i = NULL; @@ -201,6 +206,13 @@ smx_host_t SIMIX_host_get_by_name(const char *name) return NULL; } +/** + * \brief Return the state of a workstation + * + * Return the state of a workstation. Two states are possible, 1 if the host is active or 0 if it has crashed. + * \param host The SIMIX host + * \return 1 if host is available or 0 if not. + */ int SIMIX_host_get_state(smx_host_t host) { xbt_assert0((host!= NULL), "Invalid parameters");