From: mquinson Date: Mon, 10 May 2010 14:53:27 +0000 (+0000) Subject: MSG_task_isend/irecv and MSG_comm_test/wait added in a rush (not quite tested, not... X-Git-Tag: SVN~12 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/21fc017851c91d36664e76311041cffd1e3e977a MSG_task_isend/irecv and MSG_comm_test/wait added in a rush (not quite tested, not documented at all yet) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7732 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index 3415d07656..d336b6dddc 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -65,6 +65,7 @@ SG_BEGIN_DECL() */ #define MSG_TASK_UNINITIALIZED NULL + typedef struct s_smx_comm *msg_comm_t; /** @} */ diff --git a/include/msg/msg.h b/include/msg/msg.h index 8eaa724379..6d4027fb38 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -165,6 +165,12 @@ XBT_PUBLIC(MSG_error_t) XBT_PUBLIC(MSG_error_t) MSG_task_receive(m_task_t * task, const char *alias); +XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias); +XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias); +XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm); +XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm,double timeout); + + XBT_PUBLIC(int) MSG_task_listen(const char *alias); XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias, m_host_t host); diff --git a/src/msg/gos.c b/src/msg/gos.c index 4e90b14b79..0b22f51614 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -404,6 +404,93 @@ MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout, timeout); } +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); +} + +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); +} +int MSG_comm_test(msg_comm_t comm) { + return SIMIX_network_test(comm); +} +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); + // (*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 Put a task on a channel of an host and waits for the end of the