Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding debug informations.
[simgrid.git] / src / simix / smx_host.c
index 2326036..6501627 100644 (file)
@@ -1,6 +1,7 @@
 /*     $Id$     */
 
-/* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved.        */
+/* Copyright (c) 2007 Arnaud Legrand, Bruno Donassolo.
+   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. */
@@ -40,7 +41,7 @@ smx_host_t __SIMIX_host_create(const char *name,
 
   simdata->host = workstation;
 
-  simdata->process_list = xbt_swag_new(xbt_swag_offset(proc, process_hookup));
+  simdata->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
   /* Update global variables */
 
   xbt_fifo_unshift(simix_global->host, host);
@@ -55,7 +56,7 @@ smx_host_t __SIMIX_host_create(const char *name,
  * 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.
  */
-SIMIX_error_t SIMIX_host_set_data(smx_host_t host, void *data)
+void SIMIX_host_set_data(smx_host_t host, void *data)
 {
   xbt_assert0((host!=NULL), "Invalid parameters");
   xbt_assert0((host->data == NULL), "Data already set");
@@ -63,7 +64,7 @@ SIMIX_error_t SIMIX_host_set_data(smx_host_t host, void *data)
   /* Assign data */
   host->data = data;
 
-  return SIMIX_OK;
+  return ;
 }
 
 /** \ingroup m_host_management
@@ -120,7 +121,7 @@ void __SIMIX_host_destroy(smx_host_t host)
 
  
   /* Clean Simulator data */
-  simdata = (host)->simdata;
+  simdata = host->simdata;
 
   xbt_assert0((xbt_swag_size(simdata->process_list)==0),
              "Some process are still running on this host");
@@ -138,7 +139,7 @@ void __SIMIX_host_destroy(smx_host_t host)
 /** \ingroup m_host_management
  * \brief Return the current number of #m_host_t.
  */
-int SIMIX_get_host_number(void)
+int SIMIX_host_get_number(void)
 {
   return (xbt_fifo_size(simix_global->host));
 }
@@ -146,36 +147,30 @@ int SIMIX_get_host_number(void)
 /** \ingroup m_host_management
  * \brief Return a array of all the #m_host_t.
  */
-smx_host_t *SIMIX_get_host_table(void)
+smx_host_t *SIMIX_host_get_table(void)
 {
   return ((smx_host_t *)xbt_fifo_to_array(simix_global->host));
 }
 
+
 /** \ingroup m_host_management
- * \brief Return the number of MSG tasks currently running on a
* #m_host_t. The external load is not taken in account.
+ * \brief Return the speed of the processor (in Mflop/s), regardless of 
   the current load on the machine.
  */
-/*
-int MSG_get_host_msgload(m_host_t h)
+double SIMIX_host_get_speed(smx_host_t host)
 {
-  xbt_assert0((h!= NULL), "Invalid parameters");
-  xbt_assert0(0, "Not implemented yet");
+  xbt_assert0((host!= NULL), "Invalid parameters");
 
-  return(0);
-//   return(surf_workstation_resource->extension_public->get_load(h->simdata->host));
+  return(surf_workstation_resource->
+        extension_public->get_speed(host->simdata->host,1.0));
 }
-*/
 
-/** \ingroup m_host_management
- * \brief Return the speed of the processor (in Mflop/s), regardless of 
-    the current load on the machine.
- */
-double SIMIX_get_host_speed(smx_host_t h)
+double SIMIX_host_get_available_speed(smx_host_t host)
 {
-  xbt_assert0((h!= NULL), "Invalid parameters");
+  xbt_assert0((host!= NULL), "Invalid parameters");
 
   return(surf_workstation_resource->
-        extension_public->get_speed(h->simdata->host,1.0));
+        extension_public->get_available_speed(host->simdata->host));
 }
 
 /** \ingroup msg_gos_functions
@@ -183,16 +178,36 @@ double SIMIX_get_host_speed(smx_host_t h)
  *
  * \param h host to test
  */
-int SIMIX_host_is_avail (smx_host_t h)
+
+/** \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)
 {
-  e_surf_cpu_state_t cpustate;
-  xbt_assert0((h!= NULL), "Invalid parameters");
+  xbt_fifo_item_t i = NULL;
+  smx_host_t host = NULL;
+
+  xbt_assert0(((simix_global != NULL)
+         && (simix_global->host != NULL)), "Environment not set yet");
+
+  xbt_fifo_foreach(simix_global->host,i,host,smx_host_t) {
+    if(strcmp(host->name, name) == 0) return host;
+  }
+  return NULL;
+}
 
-  cpustate =
-    surf_workstation_resource->extension_public->get_state(h->simdata->host);
+int SIMIX_host_get_state(smx_host_t host)
+{
+  xbt_assert0((host!= NULL), "Invalid parameters");
 
-  xbt_assert0((cpustate == SURF_CPU_ON || cpustate == SURF_CPU_OFF),
-             "Invalid cpu state");
+  return(surf_workstation_resource->
+        extension_public->get_state(host->simdata->host));
 
-  return (cpustate==SURF_CPU_ON);
 }
+
+