Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
surf:~/Work/GRAS/heap $ valgrind --leak-check=yes --show-reachable=yes ./msg_test les
[simgrid.git] / src / msg / environment.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved.        */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include"private.h"
9 #include"xbt/sysdep.h"
10 #include "xbt/error.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(environment, msg,
12                                 "Logging specific to MSG (environment)");
13
14 /********************************* MSG **************************************/
15
16 /** \ingroup msg_easier_life
17  * \brief A name directory service...
18  *
19  * Finds a m_host_t using its name.
20  * \param name the name of an host.
21  * \return the corresponding host
22  */
23 m_host_t MSG_get_host_by_name(const char *name)
24 {
25   xbt_fifo_item_t i = NULL;
26   m_host_t host = NULL;
27
28   xbt_assert0(((msg_global != NULL)
29           && (msg_global->host != NULL)), "Environment not set yet");
30
31   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
32     if(strcmp(host->name, name) == 0) return host;
33   }
34   return NULL;
35 }
36
37 /** \ingroup msg_easier_life
38  * \brief A platform constructor.
39  *
40  * Creates a new platform, including hosts, links and the
41  * routing_table. 
42  * \param file a filename of a description of a platform. This file is a simple text 
43  * file in which you can use C-style comments and C-style strings.
44  * Here is a simple description of the format:
45  \verbatim
46 <CPU>
47 host_name "power in MFlops" "availability" "availability file" ON/OFF "failure file"
48 host_name "power in MFlops" "availability" "availability file" ON/OFF "failure file"
49 ...
50 </LINKS>
51 link_name "bandwidth in Mbytes" "bandwidth file" "latency in ms" "latency file"
52 link_name "bandwidth in Mbytes" "bandwidth file" "latency in ms" "latency file"
53 ...
54 ROUTES
55 src_name dst_name (link_name link_name link_name ... )
56 src_name dst_name (link_name link_name link_name ... )
57 ...
58 \endverbatim
59  * Have a look in the directory examples/msg/ to have a better idea of what
60  * it looks like.
61  */
62 void MSG_create_environment(const char *file) {
63   xbt_dict_cursor_t cursor = NULL;
64   char *name = NULL;
65   void *workstation = NULL;
66
67   surf_workstation_resource_init(file);
68
69   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
70     __MSG_host_create(name, workstation, NULL);
71   }
72
73   return;
74 }
75