From bb0b31ac5c18fc8bc05bd9371d9b2254cd62bba4 Mon Sep 17 00:00:00 2001 From: suter Date: Fri, 23 Oct 2009 05:59:09 +0000 Subject: [PATCH] small improvements suggested by Arnaud git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6813 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/msg/actions/actions.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/examples/msg/actions/actions.c b/examples/msg/actions/actions.c index b6b74897a4..d60901c2ef 100644 --- a/examples/msg/actions/actions.c +++ b/examples/msg/actions/actions.c @@ -10,10 +10,6 @@ #include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ #include "xbt.h" /* calloc, printf */ -typedef enum { - LOCAL = 0, - MAX_CHANNEL -} channel_t; XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); @@ -62,9 +58,7 @@ static int spawned_recv(int argc, char *argv[]) INFO1("Receiving on %s", name); MSG_task_receive(&task, name); INFO1("Received %s", MSG_task_get_name(task)); - - MSG_task_put(MSG_task_create("waiter", 0, 0, NULL), - MSG_process_get_host(MSG_process_self()), LOCAL); + MSG_task_send(MSG_task_create("waiter",0,0,NULL),MSG_process_self()->name); MSG_task_destroy(task); return 0; @@ -75,24 +69,27 @@ static void Irecv(xbt_dynar_t action) char *name = xbt_str_join(action, " "); m_process_t comm_helper; - INFO1("Irecv on %s: spawn process ", + INFO1("Irecv on %s: spawn process ", MSG_process_get_name(MSG_process_self())); - comm_helper = - MSG_process_create("spawned_recv", - spawned_recv, - (void *) MSG_process_get_name(MSG_process_self()), - MSG_process_get_host(MSG_process_self())); - + sprintf(name,"%s_wait",MSG_process_self()->name); + comm_helper = MSG_process_create(name,spawned_recv, + (void *) MSG_process_get_name(MSG_process_self()), + MSG_host_self()); + + free(name); } static void wait(xbt_dynar_t action) { char *name = xbt_str_join(action, " "); + char task_name[80]; m_task_t task = NULL; + INFO1("wait: %s", name); - MSG_task_get(&(task), LOCAL); + sprintf(task_name,"%s_wait",MSG_process_self()->name); + MSG_task_receive(&task,task_name); INFO1("waited: %s", name); free(name); } @@ -134,7 +131,6 @@ int main(int argc, char *argv[]) } /* Simulation setting */ - MSG_set_channel_number(MAX_CHANNEL); MSG_create_environment(argv[1]); /* No need to register functions as in classical MSG programs: the actions get started anyway */ -- 2.20.1