Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First try at actually using the configuration stuff. MSG acts as cobaye here
[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 /** \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  */
19
20 /********************************* MSG **************************************/
21
22 /** \ingroup msg_easier_life
23  * \brief A name directory service...
24  *
25  * Finds a m_host_t using its name.
26  * \param name the name of an host.
27  * \return the corresponding host
28  */
29 m_host_t MSG_get_host_by_name(const char *name)
30 {
31   xbt_fifo_item_t i = NULL;
32   m_host_t host = NULL;
33
34   xbt_assert0(((msg_global != NULL)
35           && (msg_global->host != NULL)), "Environment not set yet");
36
37   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
38     if(strcmp(host->name, name) == 0) return host;
39   }
40   return NULL;
41 }
42
43 /** \ingroup msg_easier_life
44  * \brief A platform constructor.
45  *
46  * Creates a new platform, including hosts, links and the
47  * routing_table. 
48  * \param file a filename of a xml description of a platform. This file 
49  * follows this DTD :
50  *
51  *     \include surfxml.dtd
52  *
53  * Here is a small example of such a platform 
54  *
55  *     \include small_platform.xml
56  *
57  * Have a look in the directory examples/msg/ to have a big example.
58  */
59 void MSG_create_environment(const char *file) {
60   xbt_dict_cursor_t cursor = NULL;
61   char *name = NULL;
62   void *workstation = NULL;
63   char *workstation_model_name;
64
65   msg_config_init(); /* make sure that our configuration set is created */
66   surf_timer_resource_init(file);
67
68   /* which model do you want today? */
69   xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model",
70                       &workstation_model_name);
71   if (!strcmp(workstation_model_name,"KCCFLN05")) {
72     surf_workstation_resource_init_KCCFLN05(file);
73   } else if (!strcmp(workstation_model_name,"CLM03")) {
74     surf_workstation_resource_init_CLM03(file);
75   } else {
76     xbt_assert0(0,"The impossible happened (once again)");
77   }
78   _msg_init_status = 2; /* inited; don't change settings now */
79
80   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
81     __MSG_host_create(name, workstation, NULL);
82   }
83
84   return;
85 }
86