XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_masterworker, "Messages specific for this msg example");
-/* Main function of the master process. It expects 4 arguments given in the XML deployment file: */
+/* Main function of the master process */
static int master(int argc, char *argv[])
{
+ xbt_assert(argc==5, "The master function expects 4 arguments from the XML deployment file");
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - Number of tasks */
double comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - Task compute cost */
double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - Task communication size */
long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s"); /* - Number of workers */
- int i;
-
XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
- for (i = 0; i < number_of_tasks; i++) { /* For each task to be executed: */
- char mailbox[256];
- char task_name[256];
+ for (int i = 0; i < number_of_tasks; i++) { /* For each task to be executed: */
+ char mailbox[80];
+ char task_name[80];
- snprintf(mailbox,255, "worker-%ld", i % workers_count); /* - Select a @ref worker in a round-robin way */
- snprintf(task_name,255, "Task_%d", i);
+ snprintf(mailbox,79, "worker-%ld", i % workers_count); /* - Select a @ref worker in a round-robin way */
+ snprintf(task_name,79, "Task_%d", i);
msg_task_t task = MSG_task_create(task_name, comp_size, comm_size, NULL); /* - Create a task */
if (number_of_tasks < 10000 || i % 10000 == 0)
XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
}
XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (i = 0; i < workers_count; i++) { /* - Eventually tell all the workers to stop by sending a "finalize" task */
+ for (int i = 0; i < workers_count; i++) { /* - Eventually tell all the workers to stop by sending a "finalize" task */
char mailbox[80];
snprintf(mailbox,79, "worker-%ld", i % workers_count);
return 0;
}
-/* Main functions of the Worker processes. It expects a single argument given in the XML deployment file: the unique ID of the worker. */
+/* Main functions of the Worker processes */
static int worker(int argc, char *argv[])
{
- msg_task_t task = NULL;
+ xbt_assert(argc==2, "The worker expects a single argument from the XML deployment file: its worker ID (its numerical rank)");
char mailbox[80];
long id= xbt_str_parse_int(argv[1], "Invalid argument %s");
snprintf(mailbox,79, "worker-%ld", id);
while (1) { /* The worker wait in an infinite loop for tasks sent by the \ref master */
- int res = MSG_task_receive(&(task), mailbox);
+ msg_task_t task = NULL;
+ int res = MSG_task_receive(&task, mailbox);
xbt_assert(res == MSG_OK, "MSG_task_get failed");
if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
}
MSG_task_execute(task); /* - Otherwise, process the task */
MSG_task_destroy(task);
- task = NULL;
}
XBT_INFO("I'm done. See you!");
return 0;
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. 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. */
static int pinger(int argc, char *argv[])
{
+ xbt_assert(argc==2, "The pinger function one argument from the XML deployment file");
XBT_INFO("Ping -> %s", argv[1]);
xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);
/* - Do the ping with a 1-Byte task (latency bound) ... */
- double time = MSG_get_clock();
+ double now = MSG_get_clock();
msg_task_t ping_task = MSG_task_create("small communication (latency bound)", 0.0, 1, NULL);
ping_task->data = xbt_new(double, 1);
- *(double *) ping_task->data = time;
+ *(double *) ping_task->data = now;
MSG_task_send(ping_task, argv[1]);
/* - ... then wait for the (large) pong */
static int ponger(int argc, char *argv[])
{
+ xbt_assert(argc==2, "The ponger function one argument from the XML deployment file");
XBT_INFO("Pong -> %s", argv[1]);
xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);
XBT_INFO(" Ping time (latency bound) %e", communication_time);
/* - ... Then send a 1GB pong back (bandwidth bound) */
- double time = MSG_get_clock();
+ double now = MSG_get_clock();
msg_task_t pong_task = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, NULL);
pong_task->data = xbt_new(double, 1);
- *(double *) pong_task->data = time;
+ *(double *) pong_task->data = now;
XBT_INFO("task_bw->data = %e", *((double *) pong_task->data));
MSG_task_send(pong_task, argv[1]);
int main(int argc, char *argv[])
{
- msg_error_t res = MSG_OK;
-
MSG_init(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
MSG_create_environment(argv[1]); /* - Load the platform description */
- MSG_function_register("pinger", pinger); /* - Register the function to be executed by the processes */
+ MSG_function_register("pinger", pinger); /* - Register the functions to be executed by the processes */
MSG_function_register("ponger", ponger);
MSG_launch_application(argv[2]); /* - Deploy the application */
- res = MSG_main(); /* - Run the simulation */
+ msg_error_t res = MSG_main(); /* - Run the simulation */
XBT_INFO("Total simulation time: %e", MSG_get_clock());
return res!=MSG_OK;
/* Main function of all processes used in this example */
static int relay_runner(int argc, char *argv[])
{
+ xbt_assert(argc==0, "The relay_runner function does not accept any parameter from the XML deployment file");
unsigned int task_comm_size = 1000000; /* The token is 1MB long*/
int rank = xbt_str_parse_int(MSG_process_get_name(MSG_process_self()), "Any process of this example must have a numerical name, not %s");
char mailbox[256];
XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name,mailbox);
MSG_task_send(task, mailbox);
task = NULL;
- int res = MSG_task_receive(&(task), MSG_process_get_name(MSG_process_self()));
+ int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
xbt_assert(res == MSG_OK, "MSG_task_get failed");
XBT_INFO("Host \"%d\" received \"%s\"", rank, MSG_task_get_name(task));
MSG_task_destroy(task);
} else {
/* The others processes receive from their left neighbor (rank-1) and send to their right neighbor (rank+1) */
msg_task_t task = NULL;
- int res = MSG_task_receive(&(task), MSG_process_get_name(MSG_process_self()));
+ int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
xbt_assert(res == MSG_OK, "MSG_task_get failed");
XBT_INFO("Host \"%d\" received \"%s\"",rank, MSG_task_get_name(task));
int main(int argc, char *argv[])
{
- unsigned int i;
MSG_init(&argc, argv);
+ xbt_assert(argc>1, "Usage: %s platform.xml\n",argv[0]);
MSG_create_environment(argv[1]); /* - Load the platform description */
xbt_dynar_t hosts = MSG_hosts_as_dynar();
- msg_host_t h;
- XBT_INFO("Number of hosts '%d'",MSG_get_host_number());
- xbt_dynar_foreach (hosts, i, h){ /* - Give a unique rank to each host and create a @ref relay_runner process on each */
+ XBT_INFO("Number of hosts '%d'", MSG_get_host_number());
+ unsigned int i;
+ msg_host_t h;
+ xbt_dynar_foreach (hosts, i, h) { /* - Give a unique rank to each host and create a @ref relay_runner process on each */
char* name_host = bprintf("%u",i);
MSG_process_create(name_host, relay_runner, NULL, h);
free(name_host);
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_wait, "Messages specific for this msg example");
-/* Sender process expects 6 arguments: */
+/* Main function of the Sender process */
static int sender(int argc, char *argv[])
{
+ xbt_assert(argc==7, "The sender function expects 6 arguments from the XML deployment file");
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - number of tasks */
double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - computational cost */
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - communication cost */
XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
- int i;
- msg_task_t task = NULL;
- msg_comm_t comm = NULL;
MSG_process_sleep(sleep_start_time);
- for (i = 0; i < number_of_tasks; i++) {
- char mailbox[256];
- char snprintf_buffer[256];
+ for (int i = 0; i < number_of_tasks; i++) {
+ char mailbox[80];
+ char taskname[80];
- snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
- snprintf(snprintf_buffer,255, "Task_%d", i);
+ snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
+ snprintf(taskname,79, "Task_%d", i);
/* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */
- task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
- comm = MSG_task_isend(task, mailbox);
+ msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size, NULL);
+ msg_comm_t comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */
MSG_comm_destroy(comm);
}
- for (i = 0; i < receivers_count; i++) {
+ for (int i = 0; i < receivers_count; i++) {
char mailbox[80];
snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- task = MSG_task_create("finalize", 0, 0, 0);
- comm = MSG_task_isend(task, mailbox);
+ msg_task_t task = MSG_task_create("finalize", 0, 0, 0);
+ msg_comm_t comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
if (sleep_test_time > 0) {
while (MSG_comm_test(comm) == 0) {
/* Receiver process expects 3 arguments: */
static int receiver(int argc, char *argv[])
{
- msg_task_t task = NULL;
- XBT_ATTRIB_UNUSED msg_error_t res;
- char mailbox[80];
- msg_comm_t res_irecv;
+ xbt_assert(argc==4, "The relay_runner function does not accept any parameter from the XML deployment file");
int id = xbt_str_parse_int(argv[1], "Invalid id: %s"); /* - unique id */
double sleep_start_time = xbt_str_parse_double(argv[2], "Invalid sleep start parameter: %s"); /* - start time */
double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s"); /* - test time */
MSG_process_sleep(sleep_start_time); /* This process first sleeps for "start time" seconds. */
+ char mailbox[80];
snprintf(mailbox,79, "receiver-%d", id);
while (1) {
- res_irecv = MSG_task_irecv(&(task), mailbox); /* Then it posts asynchronous receives (@ref MSG_task_irecv) and*/
+ msg_task_t task = NULL;
+ msg_comm_t comm = MSG_task_irecv(&task, mailbox); /* Then it posts asynchronous receives (@ref MSG_task_irecv) and*/
XBT_INFO("Wait to receive a task");
if (sleep_test_time > 0) { /* - if "test_time" is set to 0, wait on @ref MSG_comm_wait */
- while (MSG_comm_test(res_irecv) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
+ while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
MSG_process_sleep(sleep_test_time);
}
} else {
- res = MSG_comm_wait(res_irecv, -1);
+ msg_error_t res = MSG_comm_wait(comm, -1);
xbt_assert(res == MSG_OK, "MSG_task_get failed");
}
- MSG_comm_destroy(res_irecv);
+ MSG_comm_destroy(comm);
XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
if (strcmp(MSG_task_get_name(task), "finalize") == 0) { /* If the received task is "finalize", the process ends */
MSG_task_execute(task);
XBT_INFO("\"%s\" done", MSG_task_get_name(task));
MSG_task_destroy(task);
- task = NULL;
}
XBT_INFO("I'm done. See you!");
return 0;
int main(int argc, char *argv[])
{
- msg_error_t res = MSG_OK;
-
MSG_init(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
MSG_function_register("receiver", receiver);
MSG_launch_application(argv[2]);/* - Deploy the sender and receiver processes */
- res = MSG_main(); /* - Run the simulation */
+ msg_error_t res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
static int sender(int argc, char *argv[])
{
+ xbt_assert(argc==5,"This function expects 4 parameters from the XML deployment file");
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s");
msg_comm_t *comm = xbt_new(msg_comm_t, number_of_tasks + receivers_count);
- int i;
- msg_task_t task = NULL;
- for (i = 0; i < number_of_tasks; i++) {
- char mailbox[256];
- char snprintf_buffer[256];
- snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
- snprintf(snprintf_buffer,255, "Task_%d", i);
- task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
+ for (int i = 0; i < number_of_tasks; i++) {
+ char mailbox[80];
+ char taskname[80];
+ snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
+ snprintf(taskname,79, "Task_%d", i);
+ msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size, NULL);
comm[i] = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
}
- for (i = 0; i < receivers_count; i++) {
+ for (int i = 0; i < receivers_count; i++) {
char mailbox[80];
snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- task = MSG_task_create("finalize", 0, 0, 0);
+ msg_task_t task = MSG_task_create("finalize", 0, 0, 0);
comm[i + number_of_tasks] = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
}
/* Here we are waiting for the completion of all communications */
MSG_comm_waitall(comm, (number_of_tasks + receivers_count), -1);
- for (i = 0; i < number_of_tasks + receivers_count; i++)
+ for (int i = 0; i < number_of_tasks + receivers_count; i++)
MSG_comm_destroy(comm[i]);
XBT_INFO("Goodbye now!");
static int receiver(int argc, char *argv[])
{
- msg_task_t task = NULL;
- XBT_ATTRIB_UNUSED msg_error_t res;
- int id = -1;
+ xbt_assert(argc==2,"This function expects 1 parameter from the XML deployment file");
+ int id = xbt_str_parse_int(argv[1], "Any process of this example must have a numerical name, not %s");
+
char mailbox[80];
- msg_comm_t res_irecv;
- XBT_ATTRIB_UNUSED int read;
- read = sscanf(argv[1], "%d", &id);
- xbt_assert(read, "Invalid argument %s\n", argv[1]);
- MSG_process_sleep(10);
snprintf(mailbox,79, "receiver-%d", id);
+
+ MSG_process_sleep(10);
while (1) {
- res_irecv = MSG_task_irecv(&(task), mailbox);
XBT_INFO("Wait to receive a task");
- res = MSG_comm_wait(res_irecv, -1);
- MSG_comm_destroy(res_irecv);
+ msg_task_t task = NULL;
+ msg_comm_t comm = MSG_task_irecv(&task, mailbox);
+ msg_error_t res = MSG_comm_wait(comm, -1);
xbt_assert(res == MSG_OK, "MSG_task_get failed");
+ MSG_comm_destroy(comm);
XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
MSG_task_destroy(task);
MSG_task_execute(task);
XBT_INFO("\"%s\" done", MSG_task_get_name(task));
MSG_task_destroy(task);
- task = NULL;
}
XBT_INFO("I'm done. See you!");
return 0;
int main(int argc, char *argv[])
{
- msg_error_t res = MSG_OK;
-
MSG_init(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
MSG_function_register("receiver", receiver);
MSG_launch_application(argv[2]);
- res = MSG_main();
+ msg_error_t res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
<!-- The receiver processes -->
<process host="Ruby" function="receiver">
<argument value="0"/>
- <argument value="3"/> <!-- Number of tasks -->
</process>
</platform>
static int sender(int argc, char *argv[])
{
+ xbt_assert(argc==6, "This function expects 5 parameters from the XML deployment file");
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s");
int diff_com = xbt_str_parse_int(argv[5], "Invalid value for diff_comm: %s");
- double coef = 0;
- xbt_dynar_t d = xbt_dynar_new(sizeof(msg_comm_t), NULL);
- int i;
- msg_task_t task;
- char mailbox[256];
- char snprintf_buffer[256];
- msg_comm_t comm;
-
- for (i = 0; i < number_of_tasks; i++) {
- if (diff_com == 0)
- coef = 1;
- else
- coef = (i + 1);
-
- snprintf(mailbox,255, "receiver-%ld", (i % receivers_count));
- snprintf(snprintf_buffer,255, "Task_%d", i);
- task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size / coef, NULL);
- comm = MSG_task_isend(task, mailbox);
- xbt_dynar_push_as(d, msg_comm_t, comm);
- XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, snprintf_buffer, task_comm_size / coef);
+
+ xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
+ /* First pack the communications in the dynar */
+ for (int i = 0; i < number_of_tasks; i++) {
+ double coef = (diff_com == 0) ? 1 : (i + 1);
+
+ char mailbox[80];
+ char taskname[80];
+ snprintf(mailbox,79, "receiver-%ld", (i % receivers_count));
+ snprintf(taskname,79, "Task_%d", i);
+ msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size / coef, NULL);
+ msg_comm_t comm = MSG_task_isend(task, mailbox);
+ xbt_dynar_push_as(comms, msg_comm_t, comm);
+ XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, taskname, task_comm_size / coef);
}
+
/* Here we are waiting for the completion of all communications */
-
- while (xbt_dynar_is_empty(d) == 0) {
- xbt_dynar_remove_at(d, MSG_comm_waitany(d), &comm);
+ while (xbt_dynar_is_empty(comms) == 0) {
+ msg_comm_t comm;
+ xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &comm);
MSG_comm_destroy(comm);
}
- xbt_dynar_free(&d);
+ xbt_dynar_free(&comms);
/* Here we are waiting for the completion of all tasks */
- msg_comm_t res_irecv;
- XBT_ATTRIB_UNUSED msg_error_t res_wait;
- for (i = 0; i < receivers_count; i++) {
- task = NULL;
- res_irecv = MSG_task_irecv(&(task), "finalize");
- res_wait = MSG_comm_wait(res_irecv, -1);
+ for (int i = 0; i < receivers_count; i++) {
+ msg_task_t task = NULL;
+ msg_comm_t comm = MSG_task_irecv(&task, "finalize");
+ msg_error_t res_wait = MSG_comm_wait(comm, -1);
xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed");
- MSG_comm_destroy(res_irecv);
+ MSG_comm_destroy(comm);
MSG_task_destroy(task);
}
static int receiver(int argc, char *argv[])
{
- int id = -1;
- char mailbox[80];
+ xbt_assert(argc==3, "This function expects 2 parameters from the XML deployment file");
+ int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s");
+ int task_amount = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s");
+ msg_task_t *tasks = xbt_new(msg_task_t, task_amount);
xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
- int tasks = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s");
- msg_task_t *task = xbt_new(msg_task_t, tasks);
- XBT_ATTRIB_UNUSED int read;
- read = sscanf(argv[1], "%d", &id);
- xbt_assert(read, "Invalid argument %s\n", argv[1]);
+ char mailbox[80];
snprintf(mailbox,79, "receiver-%d", id);
+
MSG_process_sleep(10);
- msg_comm_t res_irecv;
- for (int i = 0; i < tasks; i++) {
+ for (int i = 0; i < task_amount; 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);
+ tasks[i] = NULL;
+ msg_comm_t comm = MSG_task_irecv(&tasks[i], mailbox);
+ xbt_dynar_push_as(comms, msg_comm_t, comm);
}
/* Here we are waiting for the receiving of all communications */
- msg_task_t task_com;
while (!xbt_dynar_is_empty(comms)) {
- XBT_ATTRIB_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);
- XBT_INFO("Processing \"%s\"", MSG_task_get_name(task_com));
- MSG_task_execute(task_com);
- XBT_INFO("\"%s\" done", MSG_task_get_name(task_com));
- err = MSG_task_destroy(task_com);
+ msg_comm_t comm;
+ // MSG_comm_waitany returns the rank of the comm that just ended. Remove it.
+ xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &comm);
+ msg_task_t task = MSG_comm_get_task(comm);
+ MSG_comm_destroy(comm);
+ XBT_INFO("Processing \"%s\"", MSG_task_get_name(task));
+ MSG_task_execute(task);
+ XBT_INFO("\"%s\" done", MSG_task_get_name(task));
+ msg_error_t err = MSG_task_destroy(task);
xbt_assert(err == MSG_OK, "MSG_task_destroy failed");
}
xbt_dynar_free(&comms);
- xbt_free(task);
+ xbt_free(tasks);
/* Here we tell to sender that all tasks are done */
- res_irecv = MSG_task_isend(MSG_task_create(NULL, 0, 0, NULL), "finalize");
- MSG_comm_wait(res_irecv, -1);
- MSG_comm_destroy(res_irecv);
+ MSG_task_send(MSG_task_create(NULL, 0, 0, NULL), "finalize");
XBT_INFO("I'm done. See you!");
return 0;
}
int main(int argc, char *argv[])
{
- msg_error_t res = MSG_OK;
-
MSG_init(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
MSG_function_register("receiver", receiver);
MSG_launch_application(argv[2]);
- res = MSG_main();
+ msg_error_t res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());