+ DEBUG1("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",alias);
+ return MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task, host,
+ timeout);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Send a task on a channel.
+ *
+ * This function takes two parameter.
+ * \param task a #m_task_t to send on another location.
+ * \param alias the channel on which the agent should put this
+ task. This value has to be >=0 and < than the maximal number of
+ channels fixed with MSG_set_channel_number().
+ * \return the msg_comm_t communication.
+ */
+msg_comm_t MSG_task_isend(m_task_t task, const char *alias) {
+ simdata_task_t t_simdata = NULL;
+ m_process_t process = MSG_process_self();
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
+
+ CHECK_HOST();
+
+ /* FIXME: these functions are not tracable */
+
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = MSG_host_self();
+
+ xbt_assert0(t_simdata->refcount == 1,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+
+ t_simdata->refcount++;
+ msg_global->sent_msg++;
+ process->simdata->waiting_task = task;
+
+ /* Send it by calling SIMIX network layer */
+
+ /* Kept for semantical compatibility with older implementation */
+ if(mailbox->cond)
+ SIMIX_cond_signal(mailbox->cond);
+
+ return SIMIX_network_isend(mailbox->rdv, t_simdata->message_size, t_simdata->rate,
+ task, sizeof(void*), &t_simdata->comm);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Listen on a channel for receiving a task from an asynchronous communication.
+ *
+ * It takes two parameters.
+ * \param task a memory location for storing a #m_task_t.
+ * \param alias the channel on which the agent should be
+ listening. This value has to be >=0 and < than the maximal
+ number of channels fixed with MSG_set_channel_number().
+ * \return the msg_comm_t communication.
+ */
+msg_comm_t MSG_task_irecv(m_task_t * task, const char *alias) {
+ smx_comm_t comm;
+ smx_rdv_t rdv = MSG_mailbox_get_by_alias(alias)->rdv;
+ msg_mailbox_t mailbox=MSG_mailbox_get_by_alias(alias);
+ size_t size = sizeof(void*);
+
+ CHECK_HOST();
+
+ /* FIXME: these functions are not tracable */
+
+ memset(&comm,0,sizeof(comm));
+
+ /* Kept for compatibility with older implementation */
+ xbt_assert1(!MSG_mailbox_get_cond(mailbox),
+ "A process is already blocked on this channel %s",
+ MSG_mailbox_get_alias(mailbox));
+
+ /* Sanity check */
+ xbt_assert0(task, "Null pointer for the task storage");
+
+ if (*task)
+ CRITICAL0("MSG_task_get() was asked to write in a non empty task struct.");
+
+ /* Try to receive it by calling SIMIX network layer */
+ return SIMIX_network_irecv(rdv, task, &size);
+}
+/** \ingroup msg_gos_functions
+ * \brief Test the status of a communication.
+ *
+ * It takes one parameter.
+ * \param comm the communication to test.
+ * \return the status of the communication:
+ * TRUE : the communication is completed
+ * FALSE: the communication is incompleted
+ * If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
+ */
+int MSG_comm_test(msg_comm_t comm) {
+ return SIMIX_network_test(comm);
+}
+/** \ingroup msg_gos_functions
+ * \brief After received TRUE to MSG_comm_test(), the communication must be destroyed.
+ *
+ * It takes one parameter.
+ * \param comm the communication to destroy.
+ */
+void MSG_comm_destroy(msg_comm_t comm) {
+ if(!(comm->src_proc == SIMIX_process_self()))
+ {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+ SIMIX_communication_destroy(comm);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Wait for the completion of a communication.
+ *
+ * It takes two parameters.
+ * \param comm the communication to wait.
+ * \param timeout Wait until the communication terminates or the timeout occurs
+ * \return MSG_error_t
+ */
+MSG_error_t MSG_comm_wait(msg_comm_t comm, double timeout) {
+ xbt_ex_t e;
+ MSG_error_t res = MSG_OK;
+ TRY {
+ SIMIX_network_wait(comm,timeout);
+
+ if(!(comm->src_proc == SIMIX_process_self()))
+ {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+
+ /* FIXME: these functions are not tracable */
+ } CATCH(e){
+ switch(e.category){
+ case host_error:
+ res = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ res = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ res = MSG_TIMEOUT;
+ break;
+ default:
+ xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
+ }
+ xbt_ex_free(e);
+ }
+ return res;
+}
+
+/** \ingroup msg_gos_functions
+* \brief This function is called by a sender and permit to wait for each communication
+*
+* It takes three parameters.
+* \param comm a vector of communication
+* \param nb_elem is the size of the comm vector
+* \param timeout for each call of MSG_comm_wait
+*/
+void MSG_comm_waitall(msg_comm_t *comm,int nb_elem, double timeout) {
+ int i=0;
+ for(i=0; i<nb_elem; i++)
+ {
+ MSG_comm_wait(comm[i],timeout);
+ }
+}
+/** \ingroup msg_gos_functions
+* \brief This function wait for the first completed communication
+*
+* It takes on parameter.
+* \param comms a vector of communication
+* \return the position of the completed communication from the xbt_dynar_t.
+*/
+int MSG_comm_waitany(xbt_dynar_t comms) {
+ return SIMIX_network_waitany(comms);