+/** \brief Creates a new SIMIX action to communicate two hosts.
+ *
+ * This function creates a SURF action and allocates the data necessary to create the SIMIX action. It can raise a network_error exception if the host is unavailable.
+ * \param sender SIMIX host sender
+ * \param receiver SIMIX host receiver
+ * \param name Action name
+ * \param size Communication size (in bytes)
+ * \param rate Communication rate between hosts.
+ * \return A new SIMIX action
+ * */
+smx_action_t SIMIX_action_communicate(smx_host_t sender,
+ smx_host_t receiver, const char *name,
+ double size, double rate)
+{
+ /* check if the host is active */
+ if (surf_workstation_model->extension_public->
+ get_state(sender->simdata->host) != SURF_CPU_ON) {
+ THROW1(network_error, 0,
+ "Host %s failed, you cannot call this function", sender->name);
+ }
+ if (surf_workstation_model->extension_public->
+ get_state(receiver->simdata->host) != SURF_CPU_ON) {
+ THROW1(network_error, 0,
+ "Host %s failed, you cannot call this function",
+ receiver->name);
+ }
+
+ /* alloc structures */
+ smx_action_t act = xbt_new0(s_smx_action_t, 1);
+ act->simdata = xbt_new0(s_smx_simdata_action_t, 1);
+ smx_simdata_action_t simdata = act->simdata;
+ act->cond_list = xbt_fifo_new();
+
+ /* initialize them */
+ act->name = xbt_strdup(name);
+ simdata->source = sender;
+
+
+ simdata->surf_action = surf_workstation_model->extension_public->
+ communicate(sender->simdata->host,
+ receiver->simdata->host, size, rate);
+ surf_workstation_model->common_public->action_set_data(simdata->
+ surf_action,
+ act);