- const char *name;
- simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
- m_host_t host = xbt_new0(s_m_host_t, 1);
- int i;
-
- name = SIMIX_host_get_name(workstation);
- /* Host structure */
- host->name = xbt_strdup(name);
- host->simdata = simdata;
- host->data = data;
-
- simdata->smx_host = workstation;
-
- simdata->mbox = xbt_new0(xbt_fifo_t, msg_global->max_channel);
- for (i = 0; i < msg_global->max_channel; i++)
- simdata->mbox[i] = xbt_fifo_new();
-
- simdata->sleeping = xbt_new0(smx_cond_t, msg_global->max_channel);
- simdata->mutex = SIMIX_mutex_init();
- SIMIX_host_set_data(workstation, host);
-
- /* Update global variables */
- xbt_fifo_unshift(msg_global->host, host);
-
- return host;
+ const char *name;
+ simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
+ m_host_t host = xbt_new0(s_m_host_t, 1);
+ int i;
+
+ char alias[MAX_ALIAS_NAME +1] = {0}; /* buffer used to build the key of the mailbox */
+ msg_mailbox_t mailbox;
+
+ name = SIMIX_host_get_name(workstation);
+ /* Host structure */
+ host->name = xbt_strdup(name);
+ host->simdata = simdata;
+ host->data = data;
+
+ simdata->smx_host = workstation;
+
+ simdata->mbox = xbt_new0(xbt_fifo_t, msg_global->max_channel);
+
+ for (i = 0; i < msg_global->max_channel; i++)
+ {
+ sprintf(alias,"%s:%d",name,i);
+
+ /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
+ mailbox = MSG_mailbox_new(alias);
+ MSG_mailbox_set_hostname(mailbox,name);
+ memset(alias,0,MAX_ALIAS_NAME +1);
+
+ simdata->mbox[i] = xbt_fifo_new();
+ }
+
+ simdata->sleeping = xbt_new0(smx_cond_t, msg_global->max_channel);
+ simdata->mutex = SIMIX_mutex_init();
+ SIMIX_host_set_data(workstation, host);
+
+ /* Update global variables */
+ xbt_fifo_unshift(msg_global->host, host);
+
+ return host;