2 /* Create a log channel to have nice outputs. */
5 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
6 "Messages specific for this msg example");
7 #define MAX_ITER 200000
10 int master(int argc, char **argv);
11 int slave(int argc, char **argv);
13 MSG_error_t test_all(const char *, const char *);
14 int main(int argc, char *argv[]);
16 int master(int argc, char** argv)
22 sscanf(argv[1], "%d", &id);
23 sprintf(mailbox, "slave-%d", id);
25 for(i=0; i < MAX_ITER; i++){
26 task = MSG_task_create("test", 100000000, 1, NULL);
28 for(j=0; j < WORK; j++);
30 MSG_task_send(task, mailbox);
31 XBT_INFO("Task sent to %s", mailbox);
37 int slave(int argc, char **argv)
43 sscanf(argv[1], "%d", &id);
44 sprintf(mailbox, "slave-%d", id);
46 for(i=0; i < MAX_ITER; i++){
47 MSG_task_receive(&task, mailbox);
48 XBT_INFO("Task received to %s", mailbox);
49 MSG_task_destroy(task);
57 MSG_error_t test_all(const char *platform_file,
58 const char *application_file)
60 MSG_error_t res = MSG_OK;
62 /* MSG_config("workstation/model","KCCFLN05"); */
63 { /* Simulation setting */
64 MSG_create_environment(platform_file);
66 { /* Application deployment */
67 MSG_function_register("master", master);
68 MSG_function_register("slave", slave);
69 MSG_launch_application(application_file);
73 XBT_INFO("Simulation time %g", MSG_get_clock());
75 } /* end_of_test_all */
79 int main(int argc, char *argv[])
81 MSG_error_t res = MSG_OK;
83 MSG_global_init(&argc, argv);
85 printf("Usage: %s platform_file deployment_file\n", argv[0]);
86 printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
89 res = test_all(argv[1], argv[2]);