doc/msg-tuto-src/masterworker2
doc/msg-tuto-src/masterworker3
doc/msg-tuto-src/masterworker4
-examples/msg/async-wait/async-wait
-examples/msg/async-waitall/async-waitall
-examples/msg/async-waitany/async-waitany
examples/msg/app-chainsend/chainsend
examples/msg/cloud-capping/cloud-capping
examples/msg/cloud-masterworker/cloud-masterworker
teshsuite/msg/actions-comm/actions-comm
teshsuite/msg/actions-storage/actions-storage
teshsuite/msg/app-bittorrent/bittorrent
+teshsuite/msg/async-wait/async-wait
+teshsuite/msg/async-waitall/async-waitall
+teshsuite/msg/async-waitany/async-waitany
teshsuite/msg/cloud-sharing/cloud-sharing
teshsuite/msg/concurrent_rw/concurrent_rw
teshsuite/msg/energy-ptask/energy-ptask
# C examples
-foreach(x app-masterworker app-pingpong app-token-ring async-wait async-waitall
- async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
+foreach(x app-masterworker app-pingpong app-token-ring
+ cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
dht-pastry energy-consumption energy-onoff energy-pstate energy-vm platform-failures
io-file io-remote io-storage task-priority
- plugin-hostload
- process-create process-join
+ plugin-hostload
+ process-create process-join
platform-properties process-startkilltime synchro-semaphore trace-categories
trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform
trace-process-migration trace-host-user-variables)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.h)
endforeach()
-foreach (file app-chainsend app-masterworker app-pingpong async-wait
- async-waitall async-waitany dht-kademlia dht-pastry io-remote platform-properties
+foreach (file app-chainsend app-masterworker app-pingpong dht-kademlia dht-pastry io-remote platform-properties
task-priority)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/${file}/${file}_d.xml)
endforeach()
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/network-ns3.tesh PARENT_SCOPE)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/energy-onoff/platform_onoff.xml
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_kill_d.xml PARENT_SCOPE)
foreach(x app-chainsend app-masterworker app-pingpong app-token-ring
- async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple
+ cloud-capping cloud-masterworker cloud-migration cloud-simple
cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file io-remote io-storage task-priority
process-create process-join process-startkilltime
platform-properties synchro-semaphore)
@brief Find the MSG example fitting your needs from the extensive set provided in the archive.
- @ref msg_ex_basics
- - @ref msg_ex_async
- @ref msg_ex_process
- @ref msg_ex_tracing
- @ref msg_ex_tracing_user_variables
task to dispatch to a set of several Worker processes. It is fully
commented in @ref msg_ex_master_worker.
-@section msg_ex_async Asynchronous communications
-
-In addition to the fully documented example of @ref
-MSG_ex_asynchronous_communications, there are several other examples
-shipped in the archive:
-
- - <b>Basic asynchronous communications</b>.
- @ref examples/msg/async-wait/async-wait.c \n
- Illustrates how to have non-blocking communications, that are
- communications running in the background leaving the process free
- to do something else during their completion. The main functions
- involved are @ref MSG_task_isend, @ref MSG_task_irecv, and @ref
- MSG_comm_wait.
-
- - <b>Waiting for all communications in a set</b>.
- @ref examples/msg/async-waitall/async-waitall.c\n
- The @ref MSG_comm_waitall function is useful when you want to block
- until all activities in a given set have completed.
-
- - <b>Waiting for the first completed communication in a set</b>.
- @ref examples/msg/async-waitany/async-waitany.c\n
- The @ref MSG_comm_waitany function is useful when you want to block
- until one activity of the set completes, no matter which terminates
- first.
-
@section msg_ex_process Acting on Processes
- <b>Creating processes</b>.
@example examples/msg/app-token-ring/app-token-ring.c
@example examples/msg/app-masterworker/app-masterworker.c
-@example examples/msg/async-wait/async-wait.c
-@example examples/msg/async-waitall/async-waitall.c
-@example examples/msg/async-waitany/async-waitany.c
-
@example examples/msg/process-create/process-create.c
@example examples/msg/process-startkilltime/process-startkilltime.c
# C examples
-foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes
+foreach(x actions-comm actions-storage
+ async-wait async-waitall async-waitany
+ cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes
process-daemon process-kill process-migration process-suspend process-yield
energy-ptask
trace_integration)
${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/actions-storage_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/process-yield/process-yield_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/async-waitall_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/process-yield/process-yield_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp3.0-hbp4.0.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.5-hbp1.5.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE)
foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv
+ async-wait async-waitall async-waitany
task_destroy_cancel task_listen_from task_progress
process-daemon process-kill process-migration process-suspend process-yield
energy-ptask
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_wait, "Messages specific for this msg example");
/* Main function of the Sender process */
-static int sender(int argc, char *argv[])
+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 */
- long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); /* - number of receivers */
- double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */
- double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); /* - test time */
+ 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 */
+ long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); /* - number of receivers */
+ double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */
+ double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); /* - test time */
XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
char mailbox[80];
char taskname[80];
- snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- snprintf(taskname,79, "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: */
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 */
+ if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */
while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
MSG_process_sleep(sleep_test_time);
}
}
/* Receiver process expects 3 arguments: */
-static int receiver(int argc, char *argv[])
+static int receiver(int argc, char* argv[])
{
- 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 */
+ 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 */
+ double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s"); /* - test time */
XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_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);
+ snprintf(mailbox, 79, "receiver-%d", id);
while (1) {
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(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
+ if (sleep_test_time > 0) { /* - if "test_time" is set to 0, wait on @ref MSG_comm_wait */
+ while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
MSG_process_sleep(sleep_test_time);
}
} else {
return 0;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
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]);
+ "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ argv[0], argv[0]);
- MSG_create_environment(argv[1]);/* - Load the platform description */
+ MSG_create_environment(argv[1]); /* - Load the platform description */
MSG_function_register("sender", sender);
MSG_function_register("receiver", receiver);
- MSG_launch_application(argv[2]);/* - Deploy the sender and receiver processes */
+ MSG_launch_application(argv[2]); /* - Deploy the sender and receiver processes */
- msg_error_t res = MSG_main(); /* - Run the simulation */
+ msg_error_t res = MSG_main(); /* - Run the simulation */
XBT_INFO("Simulation time %g", MSG_get_clock());
p Test1 MSG_comm_test() with Sleep_sender > Sleep_receiver
-$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 1.000000] (2:receiver@Ruby) Wait to receive a task
p Test2 MSG_comm_test() with Sleep_sender < Sleep_receiver
-$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
p Test1 MSG_comm_wait() with Sleep_sender > Sleep_receiver
-$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 1.000000] (2:receiver@Ruby) Wait to receive a task
p Test2 MSG_comm_wait() with Sleep_sender < Sleep_receiver
-$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitall, "Messages specific for this msg example");
-static int sender(int argc, char *argv[])
+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");
+ 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");
+ 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);
+ msg_comm_t* comm = xbt_new(msg_comm_t, number_of_tasks + receivers_count);
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);
+ 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);
+ comm[i] = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
}
for (int i = 0; i < receivers_count; i++) {
char mailbox[80];
- snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- msg_task_t task = MSG_task_create("finalize", 0, 0, 0);
+ snprintf(mailbox, 79, "receiver-%ld", i % receivers_count);
+ 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);
}
return 0;
}
-static int receiver(int argc, char *argv[])
+static int receiver(int argc, char* argv[])
{
- xbt_assert(argc==2,"This function expects 1 parameter from the XML deployment file");
+ 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];
- snprintf(mailbox,79, "receiver-%d", id);
+ snprintf(mailbox, 79, "receiver-%d", id);
MSG_process_sleep(10);
while (1) {
return 0;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
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]);
+ "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ argv[0], argv[0]);
MSG_create_environment(argv[1]);
MSG_function_register("sender", sender);
p Test1 MSG_comm_waitall() for sender
! output sort 19
-$ $SG_TEST_EXENV ${bindir:=.}/async-waitall ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-waitall/async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-waitall ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_2
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitany, "Messages specific for this msg example");
-static int sender(int argc, char *argv[])
+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");
+ 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");
+ 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");
xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
/* First pack the communications in the dynar */
char mailbox[80];
char taskname[80];
- snprintf(mailbox,79, "receiver-%ld", (i % receivers_count));
- snprintf(taskname,79, "Task_%d", i);
+ 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);
/* Here we are waiting for the completion of all tasks */
for (int i = 0; i < receivers_count; i++) {
- msg_task_t task = NULL;
- msg_comm_t comm = MSG_task_irecv(&task, "finalize");
+ 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(comm);
return 0;
}
-static int receiver(int argc, char *argv[])
+static int receiver(int argc, char* argv[])
{
- 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_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);
char mailbox[80];
- snprintf(mailbox,79, "receiver-%d", id);
+ snprintf(mailbox, 79, "receiver-%d", id);
MSG_process_sleep(10);
for (int i = 0; i < task_amount; i++) {
XBT_INFO("Wait to receive task %d", i);
- tasks[i] = NULL;
+ tasks[i] = NULL;
msg_comm_t comm = MSG_task_irecv(&tasks[i], mailbox);
xbt_dynar_push_as(comms, msg_comm_t, comm);
}
return 0;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
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]);
+ "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ argv[0], argv[0]);
MSG_create_environment(argv[1]);
p Testing the MSG_comm_waitany function
! output sort 19
-$ $SG_TEST_EXENV ${bindir:=.}/async-waitany ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/async-waitany/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/async-waitany ${platfdir:=.}/small_platform.xml ${srcdir:=.}/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_0 comm_size 1000000.000000
> [ 0.000000] (1:sender@Tremblay) Send to receiver-1 Task_1 comm_size 1000000.000000
> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_2 comm_size 1000000.000000