From cb7ade8f9674a6833d792f3de3dc8f0658cd40bf Mon Sep 17 00:00:00 2001 From: alegrand Date: Thu, 23 Feb 2006 11:46:23 +0000 Subject: [PATCH] Adding Derrick's function to check whether a host is up or down. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1933 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/msg/msg.h | 1 + src/msg/host.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/msg/msg.h b/include/msg/msg.h index 1ad3093a90..4a570b6adb 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -38,6 +38,7 @@ m_host_t MSG_host_self(void); int MSG_get_host_msgload(m_host_t host); /* int MSG_get_msgload(void); This function lacks specification; discard it */ double MSG_get_host_speed(m_host_t h); +int MSG_host_is_avail (m_host_t h); void MSG_create_environment(const char *file); diff --git a/src/msg/host.c b/src/msg/host.c index 8e2fd41cdf..b252d89276 100644 --- a/src/msg/host.c +++ b/src/msg/host.c @@ -185,3 +185,21 @@ double MSG_get_host_speed(m_host_t h) return(surf_workstation_resource-> extension_public->get_speed(h->simdata->host,1.0)); } + +/** \ingroup msg_gos_functions + * \brief Determine if a host is available. + * + * \param host host to test + */ +int MSG_host_is_avail (m_host_t h) +{ + xbt_assert0((h!= NULL), "Invalid parameters"); + + e_surf_cpu_state_t cpustate = + surf_workstation_resource->extension_public->get_state(h->simdata->host); + + xbt_assert0((cpustate == SURF_CPU_ON || cpustate == SURF_CPU_OFF), + "Invalid cpu state"); + + return (cpustate==SURF_CPU_ON); +} -- 2.20.1