Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
92174919d5b4a79554c21dd3657f13dbe80851d7
[simgrid.git] / src / msg_simix / host.c
1 #include "private.h"
2 #include "xbt/sysdep.h"
3 #include "xbt/log.h"
4
5 /** \defgroup m_host_management Management functions of Hosts
6  *  \brief This section describes the host structure of MSG
7  * 
8  *     \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Hosts" --> \endhtmlonly
9  * (#m_host_t) and the functions for managing it.
10  *  
11  *  A <em>location</em> (or <em>host</em>) is any possible place where
12  *  a process may run. Thus it may be represented as a
13  *  <em>physical resource with computing capabilities</em>, some
14  *  <em>mailboxes</em> to enable running process to communicate with
15  *  remote ones, and some <em>private data</em> that can be only
16  *  accessed by local process.
17  *  \see m_host_t
18  */
19
20 /********************************* Host **************************************/
21 m_host_t __MSG_host_create(const char *name,
22                          void *workstation,
23                          void *data)
24 {
25   m_host_t host = xbt_new0(s_m_host_t,1);
26
27   return host;
28 }
29
30 /** \ingroup m_host_management
31  *
32  * \brief Set the user data of a #m_host_t.
33  *
34  * This functions checks whether some data has already been associated to \a host 
35    or not and attach \a data to \a host if it is possible.
36  */
37 MSG_error_t MSG_host_set_data(m_host_t host, void *data)
38 {
39   xbt_assert0((host!=NULL), "Invalid parameters");
40   xbt_assert0((host->data == NULL), "Data already set");
41
42   /* Assign data */
43   host->data = data;
44
45   return MSG_OK;
46 }
47
48 /** \ingroup m_host_management
49  *
50  * \brief Return the user data of a #m_host_t.
51  *
52  * This functions checks whether \a host is a valid pointer or not and return
53    the user data associated to \a host if it is possible.
54  */
55 void *MSG_host_get_data(m_host_t host)
56 {
57
58   xbt_assert0((host != NULL), "Invalid parameters");
59
60   /* Return data */
61   return (host->data);
62 }
63
64 /** \ingroup m_host_management
65  *
66  * \brief Return the name of the #m_host_t.
67  *
68  * This functions checks whether \a host is a valid pointer or not and return
69    its name.
70  */
71 const char *MSG_host_get_name(m_host_t host)
72 {
73
74   xbt_assert0((host != NULL) && (host->simdata != NULL), "Invalid parameters");
75
76   /* Return data */
77   return (host->name);
78 }
79
80 /** \ingroup m_host_management
81  *
82  * \brief Return the location on which the current process is executed.
83  */
84 m_host_t MSG_host_self(void)
85 {
86   return MSG_process_get_host(MSG_process_self());
87 }
88
89 /*
90  * Real function for destroy a host.
91  * MSG_host_destroy is just  a front_end that also removes it from 
92  * msg_global->host
93  */
94 void __MSG_host_destroy(m_host_t host)
95 {
96   return;
97 }
98
99 /** \ingroup m_host_management
100  * \brief Return the current number of #m_host_t.
101  */
102 int MSG_get_host_number(void)
103 {
104   return (xbt_fifo_size(msg_global->host));
105 }
106
107 /** \ingroup m_host_management
108  * \brief Return a array of all the #m_host_t.
109  */
110 m_host_t *MSG_get_host_table(void)
111 {
112   return ((m_host_t *)xbt_fifo_to_array(msg_global->host));
113 }
114
115 /** \ingroup m_host_management
116  * \brief Return the number of MSG tasks currently running on a
117  * #m_host_t. The external load is not taken in account.
118  */
119 int MSG_get_host_msgload(m_host_t h)
120 {
121   xbt_assert0((h!= NULL), "Invalid parameters");
122   xbt_assert0(0, "Not implemented yet");
123
124   return(0);
125 /*   return(surf_workstation_resource->extension_public->get_load(h->simdata->host)); */
126 }
127
128 /** \ingroup m_host_management
129  * \brief Return the speed of the processor (in flop/s), regardless of 
130     the current load on the machine.
131  */
132 double MSG_get_host_speed(m_host_t h)
133 {
134         return 0.0;
135 }
136
137 /** \ingroup msg_gos_functions
138  * \brief Determine if a host is available.
139  *
140  * \param h host to test
141  */
142 int MSG_host_is_avail (m_host_t h)
143 {
144         return 0;
145 }