Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added SDP support into surf.
[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/log.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_environment, msg,
12                                 "Logging specific to MSG (environment)");
13
14 /** \defgroup msg_easier_life      Platform and Application management
15  *  \brief This section describes functions to manage the platform creation
16  *  and the application deployment. You should also have a look at 
17  *  \ref MSG_examples  to have an overview of their usage.
18  *    \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Platforms and Applications" --> \endhtmlonly
19  * 
20  */
21
22 /********************************* MSG **************************************/
23
24 /** \ingroup msg_easier_life
25  * \brief A name directory service...
26  *
27  * Finds a m_host_t using its name.
28  * \param name the name of an host.
29  * \return the corresponding host
30  */
31 m_host_t MSG_get_host_by_name(const char *name)
32 {
33   xbt_fifo_item_t i = NULL;
34   m_host_t host = NULL;
35
36   xbt_assert0(((msg_global != NULL)
37           && (msg_global->host != NULL)), "Environment not set yet");
38
39   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
40     if(strcmp(host->name, name) == 0) return host;
41   }
42   return NULL;
43 }
44
45 /** \ingroup msg_easier_life
46  * \brief A platform constructor.
47  *
48  * Creates a new platform, including hosts, links and the
49  * routing_table. 
50  * \param file a filename of a xml description of a platform. This file 
51  * follows this DTD :
52  *
53  *     \include surfxml.dtd
54  *
55  * Here is a small example of such a platform 
56  *
57  *     \include small_platform.xml
58  *
59  * Have a look in the directory examples/msg/ to have a big example.
60  */
61 void MSG_create_environment(const char *file) {
62   xbt_dict_cursor_t cursor = NULL;
63   char *name = NULL;
64   void *workstation = NULL;
65   char *workstation_model_name;
66
67   msg_config_init(); /* make sure that our configuration set is created */
68   surf_timer_resource_init(file);
69
70   /* which model do you want today? */
71   workstation_model_name = xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model");
72
73   DEBUG1("Model : %s", workstation_model_name);
74   if (!strcmp(workstation_model_name,"KCCFLN05")) {
75     surf_workstation_resource_init_KCCFLN05(file);
76   if (!strcmp(workstation_model_name,"KCCFLN05_proportionnal")) {
77     surf_workstation_resource_init_KCCFLN05_proportionnal(file);
78   } else if (!strcmp(workstation_model_name,"CLM03")) {
79     surf_workstation_resource_init_CLM03(file);
80   } else {
81     xbt_assert0(0,"The impossible happened (once again)");
82   }
83   _msg_init_status = 2; /* inited; don't change settings now */
84
85   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
86     __MSG_host_create(name, workstation, NULL);
87   }
88
89   return;
90 }
91