Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a test for this example
[simgrid.git] / examples / msg / semaphores / synchro.c
index 5919698..7fab442 100644 (file)
@@ -4,20 +4,16 @@
 /* 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 "xbt/log.h"
 
 #include <stdlib.h>
 #include "simgrid/msg.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example");
 
 msg_sem_t sem;
 
 static int peer(int argc, char* argv[]){
 
 msg_sem_t sem;
 
 static int peer(int argc, char* argv[]){
-
   int i = 0; 
   int i = 0; 
-  
   while(i < argc) {
     double wait_time = xbt_str_parse_double(argv[i++],"Invalid wait time: %s");
     MSG_process_sleep(wait_time);
   while(i < argc) {
     double wait_time = xbt_str_parse_double(argv[i++],"Invalid wait time: %s");
     MSG_process_sleep(wait_time);
@@ -37,11 +33,11 @@ static int peer(int argc, char* argv[]){
   return 0;
 }
 
   return 0;
 }
 
-int main(int argc, char* argv[]) {
-
+int main(int argc, char* argv[])
+{
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
-  
+
   xbt_dynar_t hosts = MSG_hosts_as_dynar();
   msg_host_t h = xbt_dynar_get_as(hosts,0,msg_host_t);
 
   xbt_dynar_t hosts = MSG_hosts_as_dynar();
   msg_host_t h = xbt_dynar_get_as(hosts,0,msg_host_t);
 
@@ -69,14 +65,11 @@ int main(int argc, char* argv[]) {
   bobTimes[nbBob++] = xbt_strdup("0");
   bobTimes[nbBob++] = xbt_strdup("5");
   bobTimes[nbBob++] = NULL;
   bobTimes[nbBob++] = xbt_strdup("0");
   bobTimes[nbBob++] = xbt_strdup("5");
   bobTimes[nbBob++] = NULL;
 
 
-  MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL, 
-            h, 8, aliceTimes);
-  MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL, 
-            h, 8, bobTimes);
+  MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL, h, 8, aliceTimes);
+  MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL, h, 8, bobTimes);
 
   msg_error_t res = MSG_main();
 
   msg_error_t res = MSG_main();
-  printf("Finished\n");
+  XBT_INFO("Finished\n");
   return (res != MSG_OK);
 }
   return (res != MSG_OK);
 }