X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/12802de52c0a297e8c3253b7d9fc875c7e9cb0d9..e68d03f1f2c0206497381c7ef3b91bd5d46f1964:/examples/msg/masterslave/masterslave_failure_platfgen.c diff --git a/examples/msg/masterslave/masterslave_failure_platfgen.c b/examples/msg/masterslave/masterslave_failure_platfgen.c index 8194e32062..cec29c9258 100644 --- a/examples/msg/masterslave/masterslave_failure_platfgen.c +++ b/examples/msg/masterslave/masterslave_failure_platfgen.c @@ -1,11 +1,11 @@ -/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2007-2010, 2012-2015. 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 -#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ #include "xbt/sysdep.h" /* calloc, printf */ /* Create a log channel to have nice outputs. */ @@ -41,8 +41,8 @@ void promoter_1(context_node_t node) { static int master_choosen = FALSE; host_parameters.id = NULL; - host_parameters.power_peak = 1000000; - + host_parameters.power_peak = xbt_dynar_new(sizeof(double), NULL); + xbt_dynar_push_as(host_parameters.power_peak, double, 25000000.0); host_parameters.core_amount = 1; host_parameters.power_scale = 1; host_parameters.power_trace = NULL; @@ -55,20 +55,6 @@ void promoter_1(context_node_t node) { master_choosen = TRUE; host_parameters.id = "host_master"; } else { - /* - * The bug #14699 cannot allow us to set up an event trace which - * begin by SURF_RESOURCE_OFF, otherwise, the host will be down at startup - * and the associate process will fail to start. So, here, we generate a - * first useless event. - */ - //Set a availability trace for the node - char* generator_id = bprintf("state_host_%ld", node->id); - probabilist_event_generator_t date_generator = - tmgr_event_generator_new_weibull(generator_id, 80, 1.5); - host_parameters.state_trace = tmgr_trace_generator_state(generator_id, - date_generator, - SURF_RESOURCE_ON); - //Set a power trace char* pw_date_generator_id = bprintf("pw_date_host_%ld", node->id); char* pw_value_generator_id = bprintf("pw_value_host_%ld", node->id); @@ -121,7 +107,6 @@ void labeler_1(context_edge_t edge) { } -/** Emitter function */ int master(int argc, char *argv[]) { int slaves_count = 0; @@ -130,18 +115,17 @@ int master(int argc, char *argv[]) double task_comp_size = 0; double task_comm_size = 0; int i; - _XBT_GNUC_UNUSED int read; number_of_tasks = TASK_COUNT_PER_HOST*argc; task_comp_size = TASK_COMP_SIZE; task_comm_size = TASK_COMM_SIZE; - { /* Process organisation */ + { /* Process organization */ slaves_count = argc; slaves = xbt_new0(msg_host_t, slaves_count); for (i = 0; i < argc; i++) { - slaves[i] = MSG_get_host_by_name(argv[i]); + slaves[i] = MSG_host_by_name(argv[i]); if (slaves[i] == NULL) { XBT_INFO("Unknown host %s. Stopping Now! ", argv[i]); abort(); @@ -223,7 +207,6 @@ int master(int argc, char *argv[]) return 0; } /* end_of_master */ -/** Receiver function */ int slave(int argc, char *argv[]) { while (1) { @@ -283,7 +266,7 @@ int main(int argc, char *argv[]) int connected; int max_tries = 10; - //MSG initialisation + //MSG initialization MSG_init(&argc, argv); //Set up the seed for the platform generation @@ -313,7 +296,7 @@ int main(int argc, char *argv[]) platf_graph_promoter(promoter_1); platf_graph_labeler(labeler_1); - XBT_INFO("protmoting..."); + XBT_INFO("promoting..."); platf_do_promote(); XBT_INFO("labeling..."); @@ -329,15 +312,18 @@ int main(int argc, char *argv[]) msg_host_t host_master = NULL; msg_process_t process = NULL; xbt_dynar_t host_dynar = MSG_hosts_as_dynar(); - char** hostname_list = malloc(sizeof(char*) * xbt_dynar_length(host_dynar)); + char** hostname_list = + xbt_malloc(sizeof(char*) * xbt_dynar_length(host_dynar)); xbt_dynar_foreach(host_dynar, i, host) { process = MSG_process_create("slave", slave, NULL, host); MSG_process_auto_restart_set(process, TRUE); hostname_list[i] = (char*) MSG_host_get_name(host); } - host_master = MSG_get_host_by_name("host_master"); - MSG_process_create_with_arguments("master", master, NULL, host_master, xbt_dynar_length(host_dynar), hostname_list); + host_master = MSG_host_by_name("host_master"); + MSG_process_create_with_arguments("master", master, NULL, host_master, + xbt_dynar_length(host_dynar), + hostname_list); res = MSG_main();