X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/91715e2f198242d378e33453014dd004fcf9f47e..693f30b46244c152cd79cdf3ad35d4a79b866c9c:/examples/msg/icomms/peer3.c diff --git a/examples/msg/icomms/peer3.c b/examples/msg/icomms/peer3.c index 8b22f55b15..17ba9470c3 100644 --- a/examples/msg/icomms/peer3.c +++ b/examples/msg/icomms/peer3.c @@ -14,6 +14,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); +/** @addtogroup MSG_examples + * + * - msg/icomms/peer3.c: demonstrates the @ref MSG_comm_waitany function + */ + int sender(int argc, char *argv[]); int receiver(int argc, char *argv[]); @@ -49,7 +54,7 @@ int sender(int argc, char *argv[]) task_comm_size / coef, NULL); comm = MSG_task_isend(task, mailbox); xbt_dynar_push_as(d, msg_comm_t, comm); - INFO3("Send to receiver-%ld %s comm_size %f", i % receivers_count, + XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef); } /* Here we are waiting for the completion of all communications */ @@ -64,17 +69,17 @@ int sender(int argc, char *argv[]) sprintf(mailbox, "finalize"); msg_comm_t res_irecv; - MSG_error_t res_wait; + _XBT_GNUC_UNUSED MSG_error_t res_wait; for (i = 0; i < receivers_count; i++) { task = NULL; res_irecv = MSG_task_irecv(&(task), mailbox); res_wait = MSG_comm_wait(res_irecv, -1); - xbt_assert0(res == MSG_OK, "MSG_comm_wait failed"); + xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed"); MSG_comm_destroy(res_irecv); MSG_task_destroy(task); } - INFO0("Goodbye now!"); + XBT_INFO("Goodbye now!"); return 0; } /* end_of_sender */ @@ -88,13 +93,14 @@ int receiver(int argc, char *argv[]) int tasks = atof(argv[2]); m_task_t *task = xbt_new(m_task_t, tasks); - int read = sscanf(argv[1], "%d", &id); - xbt_assert1(read, "Invalid argument %s\n", argv[1]); + _XBT_GNUC_UNUSED int read; + read = sscanf(argv[1], "%d", &id); + xbt_assert(read, "Invalid argument %s\n", argv[1]); sprintf(mailbox, "receiver-%d", id); MSG_process_sleep(10); msg_comm_t res_irecv; for (i = 0; i < tasks; i++) { - INFO1("Wait to receive task %d", i); + XBT_INFO("Wait to receive task %d", i); task[i] = NULL; res_irecv = MSG_task_irecv(&task[i], mailbox); xbt_dynar_push_as(comms, msg_comm_t, res_irecv); @@ -103,15 +109,15 @@ int receiver(int argc, char *argv[]) /* Here we are waiting for the receiving of all communications */ m_task_t task_com; while (!xbt_dynar_is_empty(comms)) { - MSG_error_t err; + _XBT_GNUC_UNUSED MSG_error_t err; xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &res_irecv); task_com = MSG_comm_get_task(res_irecv); MSG_comm_destroy(res_irecv); - INFO1("Processing \"%s\"", MSG_task_get_name(task_com)); + XBT_INFO("Processing \"%s\"", MSG_task_get_name(task_com)); MSG_task_execute(task_com); - INFO1("\"%s\" done", MSG_task_get_name(task_com)); + XBT_INFO("\"%s\" done", MSG_task_get_name(task_com)); err = MSG_task_destroy(task_com); - xbt_assert0(err == MSG_OK, "MSG_task_destroy failed"); + xbt_assert(err == MSG_OK, "MSG_task_destroy failed"); } xbt_dynar_free(&comms); xbt_free(task); @@ -121,7 +127,7 @@ int receiver(int argc, char *argv[]) res_irecv = MSG_task_isend(MSG_task_create(NULL, 0, 0, NULL), mailbox); MSG_comm_wait(res_irecv, -1); MSG_comm_destroy(res_irecv); - INFO0("I'm done. See you!"); + XBT_INFO("I'm done. See you!"); return 0; } /* end_of_receiver */ @@ -133,7 +139,6 @@ MSG_error_t test_all(const char *platform_file, /* MSG_config("workstation/model","KCCFLN05"); */ { /* Simulation setting */ - MSG_set_channel_number(0); MSG_create_environment(platform_file); } { /* Application deployment */ @@ -143,7 +148,7 @@ MSG_error_t test_all(const char *platform_file, } res = MSG_main(); - INFO1("Simulation time %g", MSG_get_clock()); + XBT_INFO("Simulation time %g", MSG_get_clock()); return res; } /* end_of_test_all */ @@ -153,7 +158,7 @@ int main(int argc, char *argv[]) { MSG_error_t res = MSG_OK; - MSG_global_init(&argc, argv); + MSG_init(&argc, argv); if (argc < 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);