From e552466303fbb7a0de83633a72d1bb3570a11e28 Mon Sep 17 00:00:00 2001 From: alegrand Date: Fri, 14 Jan 2005 19:57:03 +0000 Subject: [PATCH] Add a forwarder in the MSG example. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@756 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- testsuite/msg/messages.h | 7 ++++++- testsuite/msg/msg_deployment.xml | 5 ++++- testsuite/msg/msg_test.c | 30 +++++++++++++++++++----------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/testsuite/msg/messages.h b/testsuite/msg/messages.h index 5571a68751..0ec66bf415 100644 --- a/testsuite/msg/messages.h +++ b/testsuite/msg/messages.h @@ -1,4 +1,9 @@ -/**** MSG_LICENCE DO NOT REMOVE ****/ +/* $Id$ */ + +/* Copyright (c) 2002,2003,2004 Arnaud Legrand. 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. */ #ifndef MESSAGES_H #define MESSAGES_H diff --git a/testsuite/msg/msg_deployment.xml b/testsuite/msg/msg_deployment.xml index f6550ac12c..5ec19e8c99 100644 --- a/testsuite/msg/msg_deployment.xml +++ b/testsuite/msg/msg_deployment.xml @@ -5,10 +5,13 @@ - + + + + diff --git a/testsuite/msg/msg_test.c b/testsuite/msg/msg_test.c index 61d57fe048..6695d538d6 100644 --- a/testsuite/msg/msg_test.c +++ b/testsuite/msg/msg_test.c @@ -1,6 +1,6 @@ /* $Id$ */ -/* Copyright (c) 2002,2004,2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2002,2003,2004 Arnaud Legrand. 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. */ @@ -134,30 +134,37 @@ int unix_receiver(int argc, char *argv[]) int unix_forwarder(int argc, char *argv[]) { - int todo_count = 0; - m_task_t *todo = (m_task_t *) calloc(NB_TASK, sizeof(m_task_t)); + m_host_t slave=NULL; int i; print_args(argc,argv); + if(argc<2) + DIE("Need somebody to which I can send my work! "); + + slave = MSG_get_host_by_name(argv[1]); + + if(slave==NULL) { + PRINT_MESSAGE("Unknown host %s. Stopping Now! \n", argv[1]); + abort(); + } + for (i = 0; i < NB_TASK;) { + m_task_t task = NULL; int a; PRINT_MESSAGE("Awaiting Task %d \n", i); - a = MSG_task_get(&(todo[i]), PORT_22); + a = MSG_task_get(&task, PORT_22); if (a == MSG_OK) { - todo_count++; - PRINT_MESSAGE("Received \"%s\" \n", todo[i]->name); - PRINT_MESSAGE("Processing \"%s\" \n", todo[i]->name); - MSG_task_execute(todo[i]); - PRINT_MESSAGE("\"%s\" done \n", todo[i]->name); - MSG_task_destroy(todo[i]); + PRINT_MESSAGE("Received \"%s\" \n", task->name); + PRINT_MESSAGE("Sending to somebody else \"%s\" \n", task->name); + MSG_task_put(task,slave,PORT_22); i++; } else { PRINT_MESSAGE("Hey ?! What's up ? \n"); DIE("Unexpected behaviour"); } } - free(todo); + PRINT_MESSAGE("I'm done. See you!\n"); return 0; } @@ -172,6 +179,7 @@ void test_all(const char *platform_file,const char *application_file) { /* Application deployment */ MSG_function_register("master", unix_emitter); MSG_function_register("slave", unix_receiver); + MSG_function_register("forwarder", unix_forwarder); MSG_launch_application(application_file); } MSG_main(); -- 2.20.1