X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/10598682c3d60c5606cd9942c0eef752ddf6856d..fcd9d7011f7e672855ff6bf17b7d7914f9e66561:/examples/msg/masterslave/masterslave_forwarder.c diff --git a/examples/msg/masterslave/masterslave_forwarder.c b/examples/msg/masterslave/masterslave_forwarder.c index 167033d608..3e6a07e6c7 100644 --- a/examples/msg/masterslave/masterslave_forwarder.c +++ b/examples/msg/masterslave/masterslave_forwarder.c @@ -1,6 +1,5 @@ -/* $Id$ */ - -/* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2007, 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. */ @@ -18,7 +17,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, int master(int argc, char *argv[]); int slave(int argc, char *argv[]); int forwarder(int argc, char *argv[]); -MSG_error_t test_all(const char *platform_file, const char *application_file); +MSG_error_t test_all(const char *platform_file, + const char *application_file); typedef enum { PORT_22 = 0, @@ -37,15 +37,14 @@ int master(int argc, char *argv[]) double task_comp_size = 0; double task_comm_size = 0; - int i; - xbt_assert1(sscanf(argv[1], "%d", &number_of_tasks), - "Invalid argument %s\n", argv[1]); - xbt_assert1(sscanf(argv[2], "%lg", &task_comp_size), - "Invalid argument %s\n", argv[2]); - xbt_assert1(sscanf(argv[3], "%lg", &task_comm_size), - "Invalid argument %s\n", argv[3]); + int res = sscanf(argv[1], "%d", &number_of_tasks); + xbt_assert1(res,"Invalid argument %s\n", argv[1]); + res = sscanf(argv[2], "%lg", &task_comp_size); + xbt_assert1(res, "Invalid argument %s\n", argv[2]); + res = sscanf(argv[3], "%lg", &task_comm_size); + xbt_assert1(res, "Invalid argument %s\n", argv[3]); { /* Task creation */ char sprintf_buffer[64]; @@ -55,7 +54,8 @@ int master(int argc, char *argv[]) for (i = 0; i < number_of_tasks; i++) { sprintf(sprintf_buffer, "Task_%d", i); todo[i] = - MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); + MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, + NULL); } } @@ -87,10 +87,11 @@ int master(int argc, char *argv[]) } INFO0 - ("All tasks have been dispatched. Let's tell everybody the computation is over."); - for (i = 0; i < slaves_count; i++) - MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE), - slaves[i], PORT_22); + ("All tasks have been dispatched. Let's tell everybody the computation is over."); + for (i = 0; i < slaves_count; i++) { + m_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE); + MSG_task_put(finalize, slaves[i], PORT_22); + } INFO0("Goodbye now!"); free(slaves); @@ -152,7 +153,7 @@ int forwarder(int argc, char *argv[]) INFO1("Received \"%s\"", MSG_task_get_name(task)); if (MSG_task_get_data(task) == FINALIZE) { INFO0 - ("All tasks have been dispatched. Let's tell everybody the computation is over."); + ("All tasks have been dispatched. Let's tell everybody the computation is over."); for (i = 0; i < slaves_count; i++) MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE), slaves[i], PORT_22); @@ -169,20 +170,20 @@ int forwarder(int argc, char *argv[]) } } xbt_free(slaves); - + INFO0("I'm done. See you!"); return 0; } /* end_of_forwarder */ /** Test function */ -MSG_error_t test_all(const char *platform_file, const char *application_file) +MSG_error_t test_all(const char *platform_file, + const char *application_file) { MSG_error_t res = MSG_OK; - /* MSG_config("surf_workstation_model","KCCFLN05"); */ + /* MSG_config("workstation/model","KCCFLN05"); */ { /* Simulation setting */ MSG_set_channel_number(MAX_CHANNEL); - MSG_paje_output("msg_test.trace"); MSG_create_environment(platform_file); } { /* Application deployment */