Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup in teshsuite/msg
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 17:26:44 +0000 (18:26 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 17:26:44 +0000 (18:26 +0100)
13 files changed:
teshsuite/msg/get_sender/get_sender.c
teshsuite/msg/host_on_off/host_on_off.c
teshsuite/msg/host_on_off/host_on_off_recv.c
teshsuite/msg/host_on_off/host_on_off_wait.c
teshsuite/msg/host_on_off_processes/host_on_off_processes.c
teshsuite/msg/listen_async/listen_async.c
teshsuite/msg/pid/pid.c
teshsuite/msg/process/process.c
teshsuite/msg/process_join/process_join.c
teshsuite/msg/storage/concurrent_rw.c
teshsuite/msg/storage/storage_basic.c
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c
teshsuite/msg/trace/test_trace_integration.c

index 592f13a..75e816f 100644 (file)
@@ -4,18 +4,15 @@
 /* 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. */
 
 /* 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 <stdio.h>
 #include "simgrid/msg.h"
 #include <float.h>
 #include "simgrid/msg.h"
 #include <float.h>
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
 
-
 static int sender_fun(int argc, char *argv[])
 {
   XBT_INFO("Sending");
   MSG_task_send(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_get_name(MSG_host_self()));
 static int sender_fun(int argc, char *argv[])
 {
   XBT_INFO("Sending");
   MSG_task_send(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_get_name(MSG_host_self()));
-  MSG_process_sleep(1.);        /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
+  MSG_process_sleep(1.);     /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
   XBT_INFO("Exiting");
   return 0;
 }
   XBT_INFO("Exiting");
   return 0;
 }
@@ -26,24 +23,21 @@ static int receiver_fun(int argc, char *argv[])
   msg_task_t task = NULL;
   MSG_task_receive_with_timeout(&task, MSG_host_get_name(MSG_host_self()), DBL_MAX);
   xbt_assert(MSG_task_get_sender(task), "No sender received");
   msg_task_t task = NULL;
   MSG_task_receive_with_timeout(&task, MSG_host_get_name(MSG_host_self()), DBL_MAX);
   xbt_assert(MSG_task_get_sender(task), "No sender received");
-  XBT_INFO("Got a message sent by '%s'",
-        MSG_process_get_name(MSG_task_get_sender(task)));
+  XBT_INFO("Got a message sent by '%s'", MSG_process_get_name(MSG_task_get_sender(task)));
   MSG_task_destroy(task);
   return 0;
 }
 
   MSG_task_destroy(task);
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
 
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
 
-  /*   Application deployment */
+  MSG_create_environment(argv[1]);
+
   MSG_function_register("send", &sender_fun);
   MSG_function_register("receive", &receiver_fun);
   MSG_function_register("send", &sender_fun);
   MSG_function_register("receive", &receiver_fun);
-
-  MSG_create_environment(argv[1]);
   MSG_launch_application(argv[2]);
   res = MSG_main();
 
   MSG_launch_application(argv[2]);
   res = MSG_main();
 
index 1c6e376..fa7b228 100644 (file)
@@ -4,21 +4,39 @@
 /* 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. */
 
 /* 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 <stdio.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 */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+static int slave(int argc, char *argv[])
+{
+  msg_task_t task = NULL;
+  XBT_ATTRIB_UNUSED int res;
+  int id = -1;
+  char mailbox[80];
+
+  sprintf(mailbox, "jupi");
+
+  while (1) {
+    res = MSG_task_receive(&(task), mailbox);
+    xbt_assert(res == MSG_OK, "MSG_task_get failed");
+
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
+    }
+    MSG_task_execute(task);
+    XBT_INFO("Task \"%s\" done", MSG_task_get_name(task));
+
+    MSG_task_destroy(task);
+    task = NULL;
+    id--;
+  }
+  XBT_INFO("I'm done. See you!");
+  return 0;
+}
 
 
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   double task_comp_size = 5E7;
   double task_comm_size = 1E6;
 {
   double task_comp_size = 5E7;
   double task_comm_size = 1E6;
@@ -69,64 +87,25 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Goodbye now!");
   return 0;
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
-{
-  msg_task_t task = NULL;
-  XBT_ATTRIB_UNUSED int res;
-  int id = -1;
-  char mailbox[80];
-
-  sprintf(mailbox, "jupi");
-
-  while (1) {
-    res = MSG_task_receive(&(task), mailbox);
-    xbt_assert(res == MSG_OK, "MSG_task_get failed");
-
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
-      MSG_task_destroy(task);
-      break;
-    }
-    MSG_task_execute(task);
-    XBT_INFO("Task \"%s\" done", MSG_task_get_name(task));
-
-    MSG_task_destroy(task);
-    task = NULL;
-    id--;
-  }
-  XBT_INFO("I'm done. See you!");
-  return 0;
-}                               /* end_of_slave */
-
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 
   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]);
-  
-  platform_file = argv[1];
-  application_file = argv[2];
-
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index 937396b..121d0b9 100644 (file)
@@ -4,24 +4,13 @@
 /* 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. */
 
 /* 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 <stdio.h>
 #include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/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 */
-#include "xbt/ex.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
-
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 static const char* mailbox = "comm";
 
 
 static const char* mailbox = "comm";
 
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   xbt_ex_t e;
   TRY {
 {
   xbt_ex_t e;
   TRY {
@@ -54,8 +43,7 @@ int master(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   xbt_ex_t e;
   TRY {
 {
   xbt_ex_t e;
   TRY {
@@ -77,31 +65,23 @@ int slave(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   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_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]);
 
-  platform_file = argv[1];
-  application_file = argv[2];
+  MSG_create_environment(argv[1]);
 
 
-  /*  Simulation setting */
-  MSG_create_environment(platform_file);
-  
-  /*   Application deployment */
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
-  MSG_launch_application(application_file);
+  MSG_launch_application(argv[2]);
 
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
 
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index 622c3cf..2bf8558 100644 (file)
@@ -4,22 +4,11 @@
 /* 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. */
 
 /* 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 <stdio.h>
 #include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/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 */
-#include "xbt/ex.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   xbt_ex_t e;
   TRY {
 {
   xbt_ex_t e;
   TRY {
@@ -38,8 +27,7 @@ int master(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   xbt_ex_t e;
   TRY {
 {
   xbt_ex_t e;
   TRY {
@@ -56,32 +44,23 @@ int slave(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 
   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]);
 
 
-  platform_file = argv[1];
-  application_file = argv[2];
+  MSG_create_environment(argv[1]);
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index 2f480e5..740a95c 100644 (file)
@@ -4,25 +4,73 @@
 /* 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. */
 
 /* 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 <stdio.h>
 #include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/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. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
-int test_launcher(int argc, char *argv[]);
-int process_daemon(int argc, char *argv[]);
-int process_sleep(int argc, char *argv[]);
-int commRX(int argc, char *argv[]);
-int commTX(int argc, char *argv[]);
-
 xbt_dynar_t tests;
 int tasks_done = 0;
 
 xbt_dynar_t tests;
 int tasks_done = 0;
 
-int test_launcher(int argc, char *argv[])
+static int process_daemon(int argc, char *argv[])
+{
+  msg_task_t task = NULL;
+  XBT_INFO("  Start daemon on %s (%f)",  MSG_host_get_name(MSG_host_self()), MSG_get_host_speed(MSG_host_self()));
+  for(;;){
+    task = MSG_task_create("daemon", MSG_get_host_speed(MSG_host_self()), 0, NULL);
+    XBT_INFO("  Execute daemon");
+    MSG_task_execute(task);
+    MSG_task_destroy(task);
+    tasks_done ++;
+  }
+  XBT_INFO("  daemon done. See you!");
+  return 0;
+}
+
+static int process_sleep(int argc, char *argv[])
+{
+  for(;;){
+    XBT_INFO("  I'm alive but I should sleep");
+    MSG_process_sleep(10);
+  }
+  XBT_INFO("  I'm done. See you!");
+  return 0;
+}
+
+static int commTX(int argc, char *argv[])
+{
+  msg_task_t task = NULL;
+  char mailbox[80];
+  sprintf(mailbox, "comm");
+  XBT_INFO("  Start TX");
+  task = MSG_task_create("COMM", 0, 100000000, NULL);
+  MSG_task_isend(task, mailbox);
+  // We should wait a bit (if not the process will end before the communication, hence an exception on the other side).
+  MSG_process_sleep(30);
+  XBT_INFO("  TX done");
+  return 0;
+}
+
+static int commRX(int argc, char *argv[])
+{
+  msg_task_t task = NULL;
+  char mailbox[80];
+  sprintf(mailbox, "comm");
+  XBT_INFO("  Start RX");
+  msg_error_t error = MSG_task_receive(&(task), mailbox);
+  if (error==MSG_OK) {
+    XBT_INFO("  Receive message: %s", task->name);
+  } else if (error==MSG_HOST_FAILURE) {
+    XBT_INFO("  Receive message: HOST_FAILURE");
+  } else if (error==MSG_TRANSFER_FAILURE) {
+    XBT_INFO("  Receive message: TRANSFERT_FAILURE");
+  } else {
+    XBT_INFO("  Receive message: %d", error);
+  }
+  XBT_INFO("  RX Done");
+  return 0;
+}
+
+static int test_launcher(int argc, char *argv[])
 {
   int test = 0;
   char **argvF;
 {
   int test = 0;
   char **argvF;
@@ -64,7 +112,9 @@ int test_launcher(int argc, char *argv[])
     MSG_host_off(jupiter);
     XBT_INFO("  sleep");
     MSG_process_sleep(10);
     MSG_host_off(jupiter);
     XBT_INFO("  sleep");
     MSG_process_sleep(10);
-    XBT_INFO("number of Process : %d it should be 1. The daemon that has been created for test2 has been correctly destroyed....ok at least it looks rigorous, cool ! You just have to disallow the possibility to create a new process on a node when the node is off.)", MSG_process_get_number());
+    XBT_INFO("number of Process : %d it should be 1. The daemon that has been created for test2 has been correctly "
+             "destroyed....ok at least it looks rigorous, cool ! You just have to disallow the possibility to create "
+             "a new process on a node when the node is off.)", MSG_process_get_number());
   }
 
    test = 3;
   }
 
    test = 3;
@@ -85,7 +135,8 @@ int test_launcher(int argc, char *argv[])
 
   test = 4;
   if (xbt_dynar_search_or_negative(tests, &test)!=-1){
 
   test = 4;
   if (xbt_dynar_search_or_negative(tests, &test)!=-1){
-    XBT_INFO("Test 4 (turn off src during a communication) : Create a Process/task to make a communication between Jupiter and Tremblay and turn off Jupiter during the communication");
+    XBT_INFO("Test 4 (turn off src during a communication) : Create a Process/task to make a communication between "
+             "Jupiter and Tremblay and turn off Jupiter during the communication");
     MSG_host_on(jupiter);
     MSG_process_sleep(10);
     argvF = xbt_new(char*, 2);
     MSG_host_on(jupiter);
     MSG_process_sleep(10);
     argvF = xbt_new(char*, 2);
@@ -98,12 +149,14 @@ int test_launcher(int argc, char *argv[])
     MSG_process_sleep(10);
     XBT_INFO("  Turn Jupiter off");
     MSG_host_off(jupiter);
     MSG_process_sleep(10);
     XBT_INFO("  Turn Jupiter off");
     MSG_host_off(jupiter);
-    XBT_INFO("Test 4 seems ok  (number of Process : %d, it should be 1 or 2 if RX has not been satisfied) cool, you can now turn off a node that has a process paused by a sleep call", MSG_process_get_number());
+    XBT_INFO("Test 4 seems ok  (number of Process : %d, it should be 1 or 2 if RX has not been satisfied) cool, you "
+             "can now turn off a node that has a process paused by a sleep call", MSG_process_get_number());
   }
 
   test = 5;
   if (xbt_dynar_search_or_negative(tests, &test)!=-1){
   }
 
   test = 5;
   if (xbt_dynar_search_or_negative(tests, &test)!=-1){
-    XBT_INFO("Test 5 (turn off dest during a communication : Create a Process/task to make a communication between Tremblay and Jupiter and turn off Jupiter during the communication");
+    XBT_INFO("Test 5 (turn off dest during a communication : Create a Process/task to make a communication between "
+             "Tremblay and Jupiter and turn off Jupiter during the communication");
     MSG_host_on(jupiter);
     MSG_process_sleep(10);
     argvF = xbt_new(char*, 2);
     MSG_host_on(jupiter);
     MSG_process_sleep(10);
     argvF = xbt_new(char*, 2);
@@ -151,99 +204,21 @@ int test_launcher(int argc, char *argv[])
     MSG_vm_shutdown(vm0);
     XBT_INFO("  Destroy vm0");
     MSG_vm_destroy(vm0);
     MSG_vm_shutdown(vm0);
     XBT_INFO("  Destroy vm0");
     MSG_vm_destroy(vm0);
-    XBT_INFO("Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)");
-  }
-
-  test = 7;
-  if (xbt_dynar_search_or_negative(tests, &test)!=-1){
-
-  }
-
-  test = 8;
-  if (xbt_dynar_search_or_negative(tests, &test)!=-1){
-
+    XBT_INFO("Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not "
+             "killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)");
   }
 
   }
 
-  test = 9;
-  if (xbt_dynar_search_or_negative(tests, &test)!=-1){
-
-  }
   XBT_INFO("  Test done. See you!");
   return 0;
 }
 
   XBT_INFO("  Test done. See you!");
   return 0;
 }
 
-int process_daemon(int argc, char *argv[])
-{
-  msg_task_t task = NULL;
-  XBT_INFO("  Start daemon on %s (%f)",  MSG_host_get_name(MSG_host_self()), MSG_get_host_speed(MSG_host_self()));
-  for(;;){
-    task = MSG_task_create("daemon", MSG_get_host_speed(MSG_host_self()), 0, NULL);
-    XBT_INFO("  Execute daemon");
-    MSG_task_execute(task);
-    MSG_task_destroy(task);
-    tasks_done ++;
-  }
-  XBT_INFO("  daemon done. See you!");
-  return 0;
-}
-
-int process_sleep(int argc, char *argv[])
-{
-  for(;;){
-    XBT_INFO("  I'm alive but I should sleep");
-    MSG_process_sleep(10);
-  }
-  XBT_INFO("  I'm done. See you!");
-  return 0;
-}
-
-int commTX(int argc, char *argv[])
-{
-  msg_task_t task = NULL;
-  char mailbox[80];
-  sprintf(mailbox, "comm");
-  XBT_INFO("  Start TX");
-  task = MSG_task_create("COMM", 0, 100000000, NULL);
-  MSG_task_isend(task, mailbox);
-  // We should wait a bit (if not the process will end before the communication, leading to an exception at the other side).
-  MSG_process_sleep(30);
-  XBT_INFO("  TX done");
-  return 0;
-}
-
-int commRX(int argc, char *argv[])
-{
-  msg_task_t task = NULL;
-  char mailbox[80];
-  sprintf(mailbox, "comm");
-  XBT_INFO("  Start RX");
-  msg_error_t error = MSG_task_receive(&(task), mailbox);
-  if (error==MSG_OK) {
-    XBT_INFO("  Receive message: %s", task->name);
-  } else if (error==MSG_HOST_FAILURE) {
-    XBT_INFO("  Receive message: HOST_FAILURE");
-  } else if (error==MSG_TRANSFER_FAILURE) {
-    XBT_INFO("  Receive message: TRANSFERT_FAILURE");
-  } else {
-    XBT_INFO("  Receive message: %d", error);
-  }
-  XBT_INFO("  RX Done");
-  return 0;
-}
-
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
 
   MSG_init(&argc, argv);
-  if (argc != 4) {
-    printf("Usage: %s platform_file deployment_file test_number\n", argv[0]);
-    printf("example: %s msg_platform.xml msg_deployment.xml 1\n", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 3,"Usage: %s platform_file deployment_file test_number\n"
+            "\tExample: %s msg_platform.xml msg_deployment.xml 1\n", argv[0], argv[0]);
 
   unsigned int iter;
   char *groups;
 
   unsigned int iter;
   char *groups;
@@ -256,22 +231,17 @@ int main(int argc, char *argv[])
   }
   xbt_dynar_free(&s_tests);
 
   }
   xbt_dynar_free(&s_tests);
 
-  platform_file = argv[1];
-  application_file = argv[2];
+  MSG_create_environment(argv[1]);
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("test_launcher", test_launcher);
-    MSG_function_register("process_daemon", process_daemon);
-    MSG_function_register("process_sleep", process_sleep);
+  MSG_function_register("test_launcher", test_launcher);
+  MSG_function_register("process_daemon", process_daemon);
+  MSG_function_register("process_sleep", process_sleep);
+
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index d32852b..3e409d6 100644 (file)
@@ -4,7 +4,6 @@
  * This occures in Java and C, but is only tested here in C.
  */
 
  * This occures in Java and C, but is only tested here in C.
  */
 
-#include <stdio.h>
 #include "simgrid/msg.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 #include "simgrid/msg.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
@@ -13,7 +12,7 @@ static int server(int argc, char *argv[])
 {
    msg_task_t task =  MSG_task_create("a", 0, 0, (char*)"Some data");
    MSG_task_isend(task, "mailbox");
 {
    msg_task_t task =  MSG_task_create("a", 0, 0, (char*)"Some data");
    MSG_task_isend(task, "mailbox");
-   
+
    xbt_assert(MSG_task_listen("mailbox")); // True (1)
    XBT_INFO("Task listen works on regular mailboxes");
    task = NULL;
    xbt_assert(MSG_task_listen("mailbox")); // True (1)
    XBT_INFO("Task listen works on regular mailboxes");
    task = NULL;
@@ -21,11 +20,11 @@ static int server(int argc, char *argv[])
    xbt_assert(!strcmp("Some data", MSG_task_get_data(task)), "Data received: %s", (char*)MSG_task_get_data(task));
    MSG_task_destroy(task);
    XBT_INFO("Data successfully received from regular mailbox");
    xbt_assert(!strcmp("Some data", MSG_task_get_data(task)), "Data received: %s", (char*)MSG_task_get_data(task));
    MSG_task_destroy(task);
    XBT_INFO("Data successfully received from regular mailbox");
-   
+
    MSG_mailbox_set_async("mailbox2");
    task = MSG_task_create("b", 0, 0, (char*)"More data");
    MSG_task_isend(task, "mailbox2");
    MSG_mailbox_set_async("mailbox2");
    task = MSG_task_create("b", 0, 0, (char*)"More data");
    MSG_task_isend(task, "mailbox2");
-   
+
    xbt_assert(MSG_task_listen("mailbox2")); // used to break.
    XBT_INFO("Task listen works on asynchronous mailboxes");
    task = NULL;
    xbt_assert(MSG_task_listen("mailbox2")); // used to break.
    XBT_INFO("Task listen works on asynchronous mailboxes");
    task = NULL;
@@ -33,11 +32,10 @@ static int server(int argc, char *argv[])
    xbt_assert(!strcmp("More data", MSG_task_get_data(task)));
    MSG_task_destroy(task);
    XBT_INFO("Data successfully received from asynchronous mailbox");
    xbt_assert(!strcmp("More data", MSG_task_get_data(task)));
    MSG_task_destroy(task);
    XBT_INFO("Data successfully received from asynchronous mailbox");
-   
+
    return 0;
 }
 
    return 0;
 }
 
-
 int main(int argc, char *argv[])
 {
    MSG_init(&argc, argv);
 int main(int argc, char *argv[])
 {
    MSG_init(&argc, argv);
@@ -45,6 +43,6 @@ int main(int argc, char *argv[])
    MSG_create_environment(argv[1]);
    MSG_process_create("test", server, NULL, MSG_host_by_name("Tremblay"));
    MSG_main();
    MSG_create_environment(argv[1]);
    MSG_process_create("test", server, NULL, MSG_host_by_name("Tremblay"));
    MSG_main();
-   
+
    return 0;
 }
    return 0;
 }
index 66c27dc..081d8c0 100644 (file)
@@ -5,10 +5,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
 const char* mailbox = "mailbox";
 #define task_comp_size 1000
 #define task_comm_size 100000
 const char* mailbox = "mailbox";
 #define task_comp_size 1000
 #define task_comm_size 100000
@@ -33,8 +32,8 @@ static int sendpid(int argc, char *argv[])
 static int killall(int argc, char *argv[]){
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
 static int killall(int argc, char *argv[]){
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
-  int i;
-  for (i=0; i<3;i++) {
+
+  for (int i=0; i<3;i++) {
     res = MSG_task_receive(&(task), mailbox);
     int pid = *(int*)MSG_task_get_data(task);
     MSG_task_destroy(task);
     res = MSG_task_receive(&(task), mailbox);
     int pid = *(int*)MSG_task_get_data(task);
     MSG_task_destroy(task);
@@ -45,14 +44,12 @@ static int killall(int argc, char *argv[]){
   return 0;
 }
 
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
 
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
 
-  /*   Application deployment */
   MSG_function_register("sendpid", &sendpid);
   MSG_function_register("killall", &killall);
 
   MSG_function_register("sendpid", &sendpid);
   MSG_function_register("killall", &killall);
 
index 5c75202..e29a615 100644 (file)
@@ -4,98 +4,73 @@
 /* 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. */
 
 /* 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 <stdio.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 */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+static int slave(int argc, char *argv[])
+{
+  MSG_process_sleep(.5);
+  XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
+  while(1){
+    XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
+    MSG_process_sleep(1);
+  }
+  XBT_INFO("I'm done. See you!");
+  return 0;
+}
 
 
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   xbt_swag_t process_list = MSG_host_get_process_list(MSG_host_self());
   msg_process_t process = NULL;
   MSG_process_sleep(1);
   xbt_swag_foreach(process, process_list) {
 {
   xbt_swag_t process_list = MSG_host_get_process_list(MSG_host_self());
   msg_process_t process = NULL;
   MSG_process_sleep(1);
   xbt_swag_foreach(process, process_list) {
-    XBT_INFO("Process(pid=%d, ppid=%d, name=%s)",
-             MSG_process_get_PID(process), MSG_process_get_PPID(process),
+    XBT_INFO("Process(pid=%d, ppid=%d, name=%s)", MSG_process_get_PID(process), MSG_process_get_PPID(process),
              MSG_process_get_name(process));
     if (MSG_process_self_PID() != MSG_process_get_PID(process))
       MSG_process_kill(process);
   }
              MSG_process_get_name(process));
     if (MSG_process_self_PID() != MSG_process_get_PID(process))
       MSG_process_kill(process);
   }
-  process = MSG_process_create("slave from master",
-                               slave, NULL, MSG_host_self());
+  process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   MSG_process_sleep(2);
 
   XBT_INFO("Suspend Process(pid=%d)", MSG_process_get_PID(process));
   MSG_process_suspend(process);
 
   MSG_process_sleep(2);
 
   XBT_INFO("Suspend Process(pid=%d)", MSG_process_get_PID(process));
   MSG_process_suspend(process);
 
-  XBT_INFO("Process(pid=%d) is %ssuspended",
-           MSG_process_get_PID(process),
+  XBT_INFO("Process(pid=%d) is %ssuspended", MSG_process_get_PID(process),
            (MSG_process_is_suspended(process)) ? "" : "not ");
   MSG_process_sleep(2);
 
   XBT_INFO("Resume Process(pid=%d)", MSG_process_get_PID(process));
   MSG_process_resume(process);
 
            (MSG_process_is_suspended(process)) ? "" : "not ");
   MSG_process_sleep(2);
 
   XBT_INFO("Resume Process(pid=%d)", MSG_process_get_PID(process));
   MSG_process_resume(process);
 
-  XBT_INFO("Process(pid=%d) is %ssuspended",
-           MSG_process_get_PID(process),
+  XBT_INFO("Process(pid=%d) is %ssuspended", MSG_process_get_PID(process),
            (MSG_process_is_suspended(process)) ? "" : "not ");
   MSG_process_sleep(2);
   MSG_process_kill(process);
 
   XBT_INFO("Goodbye now!");
   return 0;
            (MSG_process_is_suspended(process)) ? "" : "not ");
   MSG_process_sleep(2);
   MSG_process_kill(process);
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
-{
-  MSG_process_sleep(.5);
-  XBT_INFO("Slave started (PID:%d, PPID:%d)",
-           MSG_process_self_PID(), MSG_process_self_PPID());
-  while(1){
-    XBT_INFO("Plop i am %ssuspended",
-             (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
-    MSG_process_sleep(1);
-  }
-  XBT_INFO("I'm done. See you!");
-  return 0;
-}                               /* end_of_slave */
-
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
   xbt_assert(argc == 3, "Usage: %s platform_file deployment_file\n"
 
   MSG_init(&argc, argv);
   xbt_assert(argc == 3, "Usage: %s platform_file deployment_file\n"
-       "\n Example: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
-  platform_file = argv[1];
-  application_file = argv[2];
+             "\n Example: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index e6d8f78..87f5245 100644 (file)
@@ -4,39 +4,34 @@
 /* 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. */
 
 /* 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 <stdio.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 */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+static int slave(int argc, char *argv[])
+{
+  XBT_INFO("Slave started");
+  MSG_process_sleep(3);
+  XBT_INFO("I'm done. See you!");
+  return 0;
+}
 
 
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   msg_process_t process;
 
   XBT_INFO("Start slave");
 {
   msg_process_t process;
 
   XBT_INFO("Start slave");
-  process =  MSG_process_create("slave from master",
-                               slave, NULL, MSG_host_self());
+  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   XBT_INFO("Join the slave (timeout 2)");
   MSG_process_join(process, 2);
 
   XBT_INFO("Start slave");
   XBT_INFO("Join the slave (timeout 2)");
   MSG_process_join(process, 2);
 
   XBT_INFO("Start slave");
-  process =  MSG_process_create("slave from master",
-                               slave, NULL, MSG_host_self());
+  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   XBT_INFO("Join the slave (timeout 4)");
   MSG_process_join(process, 4);
 
   XBT_INFO("Start slave");
   XBT_INFO("Join the slave (timeout 4)");
   MSG_process_join(process, 4);
 
   XBT_INFO("Start slave");
-  process =  MSG_process_create("slave from master",
-                               slave, NULL, MSG_host_self());
+  process =  MSG_process_create("slave from master", slave, NULL, MSG_host_self());
   XBT_INFO("Join the slave (timeout 2)");
   MSG_process_join(process, 2);
 
   XBT_INFO("Join the slave (timeout 2)");
   MSG_process_join(process, 2);
 
@@ -46,43 +41,25 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Goodbye now!");
   return 0;
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_master */
-
-/** Receiver function  */
-int slave(int argc, char *argv[])
-{
-  XBT_INFO("Slave started");
-  MSG_process_sleep(3);
-  XBT_INFO("I'm done. See you!");
-  return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
   xbt_assert(argc == 3, "Usage: %s platform_file deployment_file\n"
 
   MSG_init(&argc, argv);
   xbt_assert(argc == 3, "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]);
 
 
-  platform_file = argv[1];
-  application_file = argv[2];
+  MSG_create_environment(argv[1]);
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index 0e8c60a..df57ce8 100644 (file)
@@ -5,53 +5,13 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
-#include "xbt/log.h"
 #include <unistd.h>
 
 #include <unistd.h>
 
-
 #define FILENAME1 "/sd1/doc/simgrid/examples/cxx/autoDestination/Main.cxx"
 
 #define FILENAME1 "/sd1/doc/simgrid/examples/cxx/autoDestination/Main.cxx"
 
-int host(int argc, char *argv[]);
-void storage_info(msg_host_t host);
-void display_storage_properties(msg_storage_t storage);
-void dump_storage_by_name(char *name);
-void display_storage_content(msg_storage_t storage);
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
-
-
-void storage_info(msg_host_t host)
-{
-  const char* host_name = MSG_host_get_name(host);
-  XBT_INFO("*** Storage info on %s ***", host_name);
-
-  xbt_dict_cursor_t cursor = NULL;
-  char* mount_name;
-  char* storage_name;
-  msg_storage_t storage;
-
-  xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(host);
-
-  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
-  {
-    XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
-
-    storage = MSG_storage_get_by_name(storage_name);
-
-    sg_size_t free_size = MSG_storage_get_free_size(storage);
-    sg_size_t used_size = MSG_storage_get_used_size(storage);
-
-    XBT_INFO("\t\tFree size: %llu bytes", free_size);
-    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
-
-    display_storage_properties(storage);
-    dump_storage_by_name(storage_name);
-  }
-  xbt_dict_free(&storage_list);
-}
-
-void display_storage_properties(msg_storage_t storage){
+static void display_storage_properties(msg_storage_t storage){
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
   xbt_dict_t props = MSG_storage_get_properties(storage);
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
   xbt_dict_t props = MSG_storage_get_properties(storage);
@@ -59,24 +19,12 @@ void display_storage_properties(msg_storage_t storage){
     XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
     xbt_dict_foreach(props, cursor, key, data)
     XBT_INFO("\t\t'%s' -> '%s'", key, data);
     XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
     xbt_dict_foreach(props, cursor, key, data)
     XBT_INFO("\t\t'%s' -> '%s'", key, data);
-  }else{
+  } else {
   XBT_INFO("\tNo property attached.");
   }
 }
 
   XBT_INFO("\tNo property attached.");
   }
 }
 
-void dump_storage_by_name(char *name){
-  XBT_INFO("*** Dump a storage element ***");
-  msg_storage_t storage = MSG_storage_get_by_name(name);
-
-  if(storage){
-    display_storage_content(storage);
-  }
-  else{
-    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
-  }
-}
-
-void display_storage_content(msg_storage_t storage){
+static void display_storage_content(msg_storage_t storage){
   XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
   xbt_dict_cursor_t cursor = NULL;
   char *file;
   XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
   xbt_dict_cursor_t cursor = NULL;
   char *file;
@@ -91,11 +39,45 @@ void display_storage_content(msg_storage_t storage){
   xbt_dict_free(&content);
 }
 
   xbt_dict_free(&content);
 }
 
+static void dump_storage_by_name(char *name){
+  XBT_INFO("*** Dump a storage element ***");
+  msg_storage_t storage = MSG_storage_get_by_name(name);
+
+  if(storage){
+    display_storage_content(storage);
+  } else{
+    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
+  }
+}
+static void storage_info(msg_host_t host)
+{
+  const char* host_name = MSG_host_get_name(host);
+  XBT_INFO("*** Storage info on %s ***", host_name);
+
+  xbt_dict_cursor_t cursor = NULL;
+  char* mount_name;
+  char* storage_name;
+  msg_storage_t storage;
+
+  xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(host);
 
 
+  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
+    XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
+    storage = MSG_storage_get_by_name(storage_name);
 
 
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
 
 
+    XBT_INFO("\t\tFree size: %llu bytes", free_size);
+    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
 
 
-int host(int argc, char *argv[])
+    display_storage_properties(storage);
+    dump_storage_by_name(storage_name);
+  }
+  xbt_dict_free(&storage_list);
+}
+
+static int host(int argc, char *argv[])
 {
   char name[2048];
   sprintf(name,"%s%i", FILENAME1,MSG_process_self_PID());
 {
   char name[2048];
   sprintf(name,"%s%i", FILENAME1,MSG_process_self_PID());
@@ -109,24 +91,18 @@ int host(int argc, char *argv[])
   return 1;
 }
 
   return 1;
 }
 
-
 int main(int argc, char **argv)
 {
 int main(int argc, char **argv)
 {
-
-  int res, i;
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
 
   MSG_function_register("host", host);
   storage_info(MSG_host_by_name(xbt_strdup("host")));
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
 
   MSG_function_register("host", host);
   storage_info(MSG_host_by_name(xbt_strdup("host")));
-  for(i = 0 ; i<10; i++){
+  for(int i = 0 ; i<10; i++){
     MSG_process_create(xbt_strdup("host"), host, NULL, MSG_host_by_name(xbt_strdup("host")));
   }
 
     MSG_process_create(xbt_strdup("host"), host, NULL, MSG_host_by_name(xbt_strdup("host")));
   }
 
-
-
-
-  res = MSG_main();
+  int res = MSG_main();
   storage_info(MSG_host_by_name(xbt_strdup("host")));
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   storage_info(MSG_host_by_name(xbt_strdup("host")));
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
index 400c47f..cb41712 100644 (file)
@@ -5,53 +5,10 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
-void storage_info(msg_host_t host);
-void display_storage_properties(msg_storage_t storage);
-int hsm_put(const char *remote_host, const char *src, const char *dest);
-sg_size_t write_local_file(const char *dest, sg_size_t file_size);
-sg_size_t read_local_file(const char *src);
-void dump_storage_by_name(char *name);
-void display_storage_content(msg_storage_t storage);
-void get_set_storage_data(const char *storage_name);
-void dump_platform_storages(void);
-int client(int argc, char *argv[]);
-int server(int argc, char *argv[]);
-
-void storage_info(msg_host_t host)
-{
-  const char* host_name = MSG_host_get_name(host);
-  XBT_INFO("*** Storage info on %s ***", host_name);
-
-  xbt_dict_cursor_t cursor = NULL;
-  char* mount_name;
-  char* storage_name;
-  msg_storage_t storage;
-
-  xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
-
-  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
-  {
-    XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
-
-    storage = MSG_storage_get_by_name(storage_name);
-
-    sg_size_t free_size = MSG_storage_get_free_size(storage);
-    sg_size_t used_size = MSG_storage_get_used_size(storage);
-
-    XBT_INFO("\t\tFree size: %llu bytes", free_size);
-    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
-
-    display_storage_properties(storage);
-    dump_storage_by_name(storage_name);
-  }
-  xbt_dict_free(&storage_list);
-}
-
-void display_storage_properties(msg_storage_t storage){
+static void display_storage_properties(msg_storage_t storage){
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
   xbt_dict_t props = MSG_storage_get_properties(storage);
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
   xbt_dict_t props = MSG_storage_get_properties(storage);
@@ -64,31 +21,18 @@ void display_storage_properties(msg_storage_t storage){
   }
 }
 
   }
 }
 
-// Read src file on local disk and send a put message to remote host (size of message = size of src file)
-int hsm_put(const char *remote_host, const char *src, const char *dest){
-
-  // Read local src file, and return the size that was actually read
-  sg_size_t read_size = read_local_file(src);
-
-  // Send file
-  XBT_INFO("%s sends %llu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host);
-  msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest);
-  MSG_task_send(to_execute, remote_host);
-  MSG_process_sleep(.4);
-  return 1;
-}
-
-sg_size_t write_local_file(const char *dest, sg_size_t file_size)
+static sg_size_t write_local_file(const char *dest, sg_size_t file_size)
 {
   sg_size_t written;
   msg_file_t file = MSG_file_open(dest, NULL);
   written = MSG_file_write(file, file_size);
 {
   sg_size_t written;
   msg_file_t file = MSG_file_open(dest, NULL);
   written = MSG_file_write(file, file_size);
-  XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size, MSG_host_get_name(MSG_host_self()));
+  XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size,
+           MSG_host_get_name(MSG_host_self()));
   MSG_file_close(file);
   return written;
 }
 
   MSG_file_close(file);
   return written;
 }
 
-sg_size_t read_local_file(const char *src)
+static sg_size_t read_local_file(const char *src)
 {
   sg_size_t read, file_size;
   msg_file_t file = MSG_file_open(src, NULL);
 {
   sg_size_t read, file_size;
   msg_file_t file = MSG_file_open(src, NULL);
@@ -101,19 +45,20 @@ sg_size_t read_local_file(const char *src)
   return read;
 }
 
   return read;
 }
 
-void dump_storage_by_name(char *name){
-  XBT_INFO("*** Dump a storage element ***");
-  msg_storage_t storage = MSG_storage_get_by_name(name);
+// Read src file on local disk and send a put message to remote host (size of message = size of src file)
+static int hsm_put(const char *remote_host, const char *src, const char *dest){
+  // Read local src file, and return the size that was actually read
+  sg_size_t read_size = read_local_file(src);
 
 
-  if(storage){
-    display_storage_content(storage);
-  }
-  else{
-    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
-  }
+  // Send file
+  XBT_INFO("%s sends %llu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host);
+  msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest);
+  MSG_task_send(to_execute, remote_host);
+  MSG_process_sleep(.4);
+  return 1;
 }
 
 }
 
-void display_storage_content(msg_storage_t storage){
+static void display_storage_content(msg_storage_t storage){
   XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
   xbt_dict_cursor_t cursor = NULL;
   char *file;
   XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
   xbt_dict_cursor_t cursor = NULL;
   char *file;
@@ -128,7 +73,19 @@ void display_storage_content(msg_storage_t storage){
   xbt_dict_free(&content);
 }
 
   xbt_dict_free(&content);
 }
 
-void get_set_storage_data(const char *storage_name){
+static void dump_storage_by_name(char *name){
+  XBT_INFO("*** Dump a storage element ***");
+  msg_storage_t storage = MSG_storage_get_by_name(name);
+
+  if(storage){
+    display_storage_content(storage);
+  }
+  else{
+    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
+  }
+}
+
+static void get_set_storage_data(const char *storage_name){
   XBT_INFO("*** GET/SET DATA for storage element: %s ***",storage_name);
   msg_storage_t storage = MSG_storage_get_by_name(storage_name);
   char *data = MSG_storage_get_data(storage);
   XBT_INFO("*** GET/SET DATA for storage element: %s ***",storage_name);
   msg_storage_t storage = MSG_storage_get_by_name(storage_name);
   char *data = MSG_storage_get_data(storage);
@@ -140,7 +97,7 @@ void get_set_storage_data(const char *storage_name){
   xbt_free(data);
 }
 
   xbt_free(data);
 }
 
-void dump_platform_storages(void){
+static void dump_platform_storages(void){
   unsigned int cursor;
   xbt_dynar_t storages = MSG_storages_as_dynar();
   msg_storage_t storage;
   unsigned int cursor;
   xbt_dynar_t storages = MSG_storages_as_dynar();
   msg_storage_t storage;
@@ -151,7 +108,36 @@ void dump_platform_storages(void){
   xbt_dynar_free(&storages);
 }
 
   xbt_dynar_free(&storages);
 }
 
-int client(int argc, char *argv[])
+static void storage_info(msg_host_t host)
+{
+  const char* host_name = MSG_host_get_name(host);
+  XBT_INFO("*** Storage info on %s ***", host_name);
+
+  xbt_dict_cursor_t cursor = NULL;
+  char* mount_name;
+  char* storage_name;
+  msg_storage_t storage;
+
+  xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
+
+  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
+    XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
+
+    storage = MSG_storage_get_by_name(storage_name);
+
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
+
+    XBT_INFO("\t\tFree size: %llu bytes", free_size);
+    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
+
+    display_storage_properties(storage);
+    dump_storage_by_name(storage_name);
+  }
+  xbt_dict_free(&storage_list);
+}
+
+static int client(int argc, char *argv[])
 {
   hsm_put("alice","/home/doc/simgrid/examples/msg/icomms/small_platform.xml","c:\\Windows\\toto.cxx");
   hsm_put("alice","/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml","c:\\Windows\\titi.xml");
 {
   hsm_put("alice","/home/doc/simgrid/examples/msg/icomms/small_platform.xml","c:\\Windows\\toto.cxx");
   hsm_put("alice","/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml","c:\\Windows\\titi.xml");
@@ -165,7 +151,7 @@ int client(int argc, char *argv[])
   return 1;
 }
 
   return 1;
 }
 
-int server(int argc, char *argv[])
+static int server(int argc, char *argv[])
 {
   msg_task_t to_execute = NULL;
   XBT_ATTRIB_UNUSED int res;
 {
   msg_task_t to_execute = NULL;
   XBT_ATTRIB_UNUSED int res;
@@ -183,8 +169,7 @@ int server(int argc, char *argv[])
     if (!strcmp(task_name, "finalize")) { // Shutdown ...
       MSG_task_destroy(to_execute);
       break;
     if (!strcmp(task_name, "finalize")) { // Shutdown ...
       MSG_task_destroy(to_execute);
       break;
-    }
-    else if(!strcmp(task_name,"hsm_put")){// Receive file to save
+    } else if(!strcmp(task_name,"hsm_put")){// Receive file to save
       // Write file on local disk
       char *dest = MSG_task_get_data(to_execute);
       sg_size_t size_to_write = (sg_size_t)MSG_task_get_bytes_amount(to_execute);
       // Write file on local disk
       char *dest = MSG_task_get_data(to_execute);
       sg_size_t size_to_write = (sg_size_t)MSG_task_get_bytes_amount(to_execute);
@@ -207,14 +192,11 @@ int main(int argc, char *argv[])
   /* Check the arguments */
   xbt_assert(argc > 2,"Usage: %s platform_file deployment_file \n", argv[0]);
 
   /* Check the arguments */
   xbt_assert(argc > 2,"Usage: %s platform_file deployment_file \n", argv[0]);
 
-  const char *platform_file = argv[1];
-  const char *deployment_file = argv[2];
-
-  MSG_create_environment(platform_file);
+  MSG_create_environment(argv[1]);
 
   MSG_function_register("client", client);
   MSG_function_register("server", server);
 
   MSG_function_register("client", client);
   MSG_function_register("server", server);
-  MSG_launch_application(deployment_file);
+  MSG_launch_application(argv[2]);
 
   msg_error_t res = MSG_main();
   XBT_INFO("Simulated time: %g", MSG_get_clock());
 
   msg_error_t res = MSG_main();
   XBT_INFO("Simulated time: %g", MSG_get_clock());
index a2cdc76..2115622 100644 (file)
@@ -4,34 +4,22 @@
 /* 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. */
 
 /* 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 <stdio.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 */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   double task_comp_size = 5E7;
   double task_comm_size = 1E6;
   double timeout = 1;
 
   char mailbox[256];
 {
   double task_comp_size = 5E7;
   double task_comm_size = 1E6;
   double timeout = 1;
 
   char mailbox[256];
-  msg_task_t task = NULL;
-  msg_comm_t comm = NULL;
   xbt_ex_t ex;
 
   sprintf(mailbox, "jupi");
 
   xbt_ex_t ex;
 
   sprintf(mailbox, "jupi");
 
-  task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
+  msg_task_t task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
   XBT_INFO("Sending task: \"%s\"", task->name);
   MSG_task_send_with_timeout(task, mailbox, timeout);
 
   XBT_INFO("Sending task: \"%s\"", task->name);
   MSG_task_send_with_timeout(task, mailbox, timeout);
 
@@ -45,7 +33,7 @@ int master(int argc, char *argv[])
   MSG_task_destroy(task);
 
   task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
   MSG_task_destroy(task);
 
   task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
-  comm = MSG_task_isend(task, mailbox);
+  msg_comm_t comm = MSG_task_isend(task, mailbox);
   XBT_INFO("Canceling task \"%s\" during comm", task->name);
   MSG_task_cancel(task);
   TRY {
   XBT_INFO("Canceling task \"%s\" during comm", task->name);
   MSG_task_cancel(task);
   TRY {
@@ -77,7 +65,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Goodbye now!");
   return 0;
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_master */
+}
 
 static int worker_main(int argc, char *argv[])
 {
 
 static int worker_main(int argc, char *argv[])
 {
@@ -90,8 +78,7 @@ static int worker_main(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   msg_task_t task;
   XBT_ATTRIB_UNUSED int res;
 {
   msg_task_t task;
   XBT_ATTRIB_UNUSED int res;
@@ -123,10 +110,8 @@ int slave(int argc, char *argv[])
     start = MSG_get_clock();
     MSG_task_execute(task);
     end = MSG_get_clock();
     start = MSG_get_clock();
     MSG_task_execute(task);
     end = MSG_get_clock();
-    XBT_INFO("Task \"%s\" done in %f (amount %f)"
-        , MSG_task_get_name(task)
-        , end - start
-        , MSG_task_get_flops_amount(task));
+    XBT_INFO("Task \"%s\" done in %f (amount %f)", MSG_task_get_name(task), end - start,
+             MSG_task_get_flops_amount(task));
 
     MSG_task_destroy(task);
     task = NULL;
 
     MSG_task_destroy(task);
     task = NULL;
@@ -134,34 +119,26 @@ int slave(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 
   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]);
-  
-  platform_file = argv[1];
-  application_file = argv[2];
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index d0f52cf..c39732a 100644 (file)
@@ -4,21 +4,13 @@
 /* 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. */
 
 /* 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 <stdio.h>
-#include <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test_trace_integration,
-                             "Messages specific for this msg example");
-
-int test_trace(int argc, char *argv[]);
+XBT_LOG_NEW_DEFAULT_CATEGORY(test_trace_integration, "Messages specific for this msg example");
 
 /** test the trace integration cpu model */
 
 /** test the trace integration cpu model */
-int test_trace(int argc, char *argv[])
+static int test_trace(int argc, char *argv[])
 {
 {
-  msg_task_t task;
   double task_comp_size = 2800;
   double task_prio = 1.0;
 
   double task_comp_size = 2800;
   double task_prio = 1.0;
 
@@ -32,7 +24,7 @@ int test_trace(int argc, char *argv[])
   XBT_INFO("Task prio: %f", task_prio);
 
   /* Create and execute a single task. */
   XBT_INFO("Task prio: %f", task_prio);
 
   /* Create and execute a single task. */
-  task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
+  msg_task_t task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
   MSG_task_set_priority(task, task_prio);
   MSG_task_execute(task);
   MSG_task_destroy(task);
   MSG_task_set_priority(task, task_prio);
   MSG_task_execute(task);
   MSG_task_destroy(task);
@@ -42,21 +34,17 @@ int test_trace(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
-  /* Verify if the platform xml file was passed by command line. */
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s test_trace_integration_model.xml deployment.xml\n", argv[0]);
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s test_trace_integration_model.xml deployment.xml\n", argv[0]);
 
-  /* Register SimGrid process function. */
   MSG_function_register("test_trace", test_trace);
   MSG_function_register("test_trace", test_trace);
-  /* Use the same file for platform and deployment. */
   MSG_create_environment(argv[1]);
   MSG_launch_application(argv[2]);
   MSG_create_environment(argv[1]);
   MSG_launch_application(argv[2]);
-  /* Run the example. */
+
   res = MSG_main();
 
   return res != MSG_OK;
   res = MSG_main();
 
   return res != MSG_OK;