X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/44723299849907b8923bfac8f9b111bcc07f0987..792ca8f49deee03354efe006a1dec6c43d2d6b07:/src/msg/msg_mailbox.c diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index f7f344550e..409801c85f 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -1,3 +1,11 @@ +/* Mailboxes in MSG */ + +/* Copyright (c) 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "mailbox.h" #include "msg/private.h" @@ -109,10 +117,19 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host, double timeout) { xbt_ex_t e; - size_t task_size = sizeof(void*); MSG_error_t ret = MSG_OK; smx_comm_t comm; + + /* We no longer support getting a task from a specific host */ + if (host) THROW_UNIMPLEMENTED; + CHECK_HOST(); +#ifdef HAVE_TRACING + TRACE_msg_task_get_start (); + double start_time = MSG_get_clock(); +#endif + + memset(&comm,0,sizeof(comm)); /* Kept for compatibility with older implementation */ xbt_assert1(!MSG_mailbox_get_cond(mailbox), @@ -123,16 +140,12 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host, 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."); - - /* We no loger support getting a task from a specific host */ - if(host) - THROW_UNIMPLEMENTED; + CRITICAL0("MSG_task_get() was asked to write in a non empty task struct."); /* Try to receive it by calling SIMIX network layer */ TRY{ - SIMIX_network_recv(mailbox->rdv, timeout, task, &task_size, &comm); + SIMIX_network_recv(mailbox->rdv, timeout, task, NULL, &comm); + //INFO2("Got task %s from %s",(*task)->name,mailbox->alias); (*task)->simdata->refcount--; } CATCH(e){ @@ -144,14 +157,21 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host, ret = MSG_TRANSFER_FAILURE; break; case timeout_error: - ret = MSG_TRANSFER_FAILURE; + ret = MSG_TIMEOUT; break; default: - xbt_die("Unhandled SIMIX network exception"); + xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg)); } xbt_ex_free(e); } - + + if (ret != MSG_HOST_FAILURE && + ret != MSG_TRANSFER_FAILURE && + ret != MSG_TIMEOUT){ +#ifdef HAVE_TRACING + TRACE_msg_task_get_end (start_time, *task); +#endif + } MSG_RETURN(ret); } @@ -166,6 +186,11 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, CHECK_HOST(); +#ifdef HAVE_TRACING + int call_end = TRACE_msg_task_put_start (task); //must be after CHECK_HOST() +#endif + + /* Prepare the task to send */ t_simdata = task->simdata; t_simdata->sender = process; @@ -186,7 +211,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, SIMIX_cond_signal(mailbox->cond); SIMIX_network_send(mailbox->rdv, t_simdata->message_size, t_simdata->rate, - timeout, &task, sizeof(void*), &t_simdata->comm, task); + timeout, task, sizeof(void*), &t_simdata->comm, task); } CATCH(e){ @@ -198,10 +223,10 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, ret = MSG_TRANSFER_FAILURE; break; case timeout_error: - ret = MSG_TRANSFER_FAILURE; + ret = MSG_TIMEOUT; break; default: - xbt_die("Unhandled SIMIX network exception"); + xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg)); } xbt_ex_free(e); @@ -210,6 +235,8 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, } process->simdata->waiting_task = NULL; - +#ifdef HAVE_TRACING + if (call_end) TRACE_msg_task_put_end (); +#endif MSG_RETURN(ret); }