Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
indent -i2 -kr. Aaaah, I feel much better now. Sorry, my screen is
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Aug 2007 14:11:17 +0000 (14:11 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Aug 2007 14:11:17 +0000 (14:11 +0000)
*only* 1680 wide... :)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3986 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/msg/deployment.c
src/msg/environment.c
src/msg/global.c
src/msg/gos.c
src/msg/host.c
src/msg/m_process.c
src/msg/msg_config.c
src/msg/task.c

index b5d903b..aa7783a 100644 (file)
@@ -1,12 +1,12 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
  *
  * Have a look in the directory examples/msg/ to have a bigger example.
  */
  *
  * Have a look in the directory examples/msg/ to have a bigger example.
  */
-void MSG_launch_application(const char *file) 
+void MSG_launch_application(const char *file)
 {
 
 {
 
-  xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_launch_application.");
-       SIMIX_function_register_process_create(_MSG_process_create_from_SIMIX);
-       SIMIX_function_register_process_cleanup(__MSG_process_cleanup);
-       SIMIX_function_register_process_kill(_MSG_process_kill_from_SIMIX);
-   
-       SIMIX_launch_application(file);
+  xbt_assert0(msg_global,
+             "MSG_global_init_args has to be called before MSG_launch_application.");
+  SIMIX_function_register_process_create(_MSG_process_create_from_SIMIX);
+  SIMIX_function_register_process_cleanup(__MSG_process_cleanup);
+  SIMIX_function_register_process_kill(_MSG_process_kill_from_SIMIX);
 
 
-       return;
+  SIMIX_launch_application(file);
+
+  return;
 }
 
 /** \ingroup msg_easier_life
 }
 
 /** \ingroup msg_easier_life
@@ -48,10 +49,10 @@ void MSG_launch_application(const char *file)
  * \param name the reference name of the function.
  * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
  */
  * \param name the reference name of the function.
  * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
  */
-void MSG_function_register(const char *name,xbt_main_func_t code)
+void MSG_function_register(const char *name, xbt_main_func_t code)
 {
 {
-       SIMIX_function_register(name, code);
-       return;
+  SIMIX_function_register(name, code);
+  return;
 }
 
 /** \ingroup msg_easier_life
 }
 
 /** \ingroup msg_easier_life
@@ -65,4 +66,3 @@ xbt_main_func_t MSG_get_registered_function(const char *name)
 {
   return SIMIX_get_registered_function(name);
 }
 {
   return SIMIX_get_registered_function(name);
 }
-
index bc57bc6..8dfe4d0 100644 (file)
@@ -1,12 +1,12 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
  */
 m_host_t MSG_get_host_by_name(const char *name)
 {
  */
 m_host_t MSG_get_host_by_name(const char *name)
 {
-       smx_host_t simix_h = NULL;
+  smx_host_t simix_h = NULL;
 
 
-       simix_h = SIMIX_host_get_by_name(name);
-       if (simix_h == NULL) {
-               return NULL;
-       }
-       else return (m_host_t)simix_h->data;
+  simix_h = SIMIX_host_get_by_name(name);
+  if (simix_h == NULL) {
+    return NULL;
+  } else
+    return (m_host_t) simix_h->data;
 }
 
 /** \ingroup msg_easier_life
 }
 
 /** \ingroup msg_easier_life
@@ -57,19 +57,18 @@ m_host_t MSG_get_host_by_name(const char *name)
  *
  * Have a look in the directory examples/msg/ to have a big example.
  */
  *
  * Have a look in the directory examples/msg/ to have a big example.
  */
-void MSG_create_environment(const char *file) 
+void MSG_create_environment(const char *file)
 {
   smx_host_t *workstation = NULL;
 {
   smx_host_t *workstation = NULL;
-       int i;
+  int i;
 
 
-       SIMIX_create_environment(file);
+  SIMIX_create_environment(file);
 
 
-       /* Initialize MSG hosts */
-       workstation = SIMIX_host_get_table();
-       for (i=0; i< SIMIX_host_get_number();i++) {
-               __MSG_host_create(workstation[i], NULL);
-       }
-       xbt_free(workstation);
+  /* Initialize MSG hosts */
+  workstation = SIMIX_host_get_table();
+  for (i = 0; i < SIMIX_host_get_number(); i++) {
+    __MSG_host_create(workstation[i], NULL);
+  }
+  xbt_free(workstation);
   return;
 }
   return;
 }
-
index 02ece3e..602ddc4 100644 (file)
@@ -1,19 +1,20 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/virtu.h"
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/virtu.h"
-#include "xbt/ex.h" /* ex_backtrace_display */
+#include "xbt/ex.h"            /* ex_backtrace_display */
 
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)");    
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg,
+                               "Logging specific to MSG (kernel)");
 
 MSG_Global_t msg_global = NULL;
 
 
 MSG_Global_t msg_global = NULL;
 
@@ -34,7 +35,7 @@ MSG_Global_t msg_global = NULL;
  */
 void MSG_global_init_args(int *argc, char **argv)
 {
  */
 void MSG_global_init_args(int *argc, char **argv)
 {
-  MSG_global_init(argc,argv);
+  MSG_global_init(argc, argv);
 }
 
 /** \ingroup msg_simulation
 }
 
 /** \ingroup msg_simulation
@@ -42,11 +43,11 @@ void MSG_global_init_args(int *argc, char **argv)
  */
 void MSG_global_init(int *argc, char **argv)
 {
  */
 void MSG_global_init(int *argc, char **argv)
 {
-  xbt_getpid = & MSG_process_self_PID;
+  xbt_getpid = &MSG_process_self_PID;
   if (!msg_global) {
     SIMIX_global_init(argc, argv);
   if (!msg_global) {
     SIMIX_global_init(argc, argv);
-     
-    msg_global = xbt_new0(s_MSG_Global_t,1);
+
+    msg_global = xbt_new0(s_MSG_Global_t, 1);
 
     msg_global->host = xbt_fifo_new();
     msg_global->process_list = xbt_fifo_new();
 
     msg_global->host = xbt_fifo_new();
     msg_global->process_list = xbt_fifo_new();
@@ -91,7 +92,9 @@ void MSG_paje_output(const char *filename)
  */
 MSG_error_t MSG_set_channel_number(int number)
 {
  */
 MSG_error_t MSG_set_channel_number(int number)
 {
-  xbt_assert0((msg_global) && (msg_global->max_channel == 0), "Channel number already set!");
+  xbt_assert0((msg_global)
+             && (msg_global->max_channel == 0),
+             "Channel number already set!");
 
   msg_global->max_channel = number;
 
 
   msg_global->max_channel = number;
 
@@ -107,7 +110,9 @@ MSG_error_t MSG_set_channel_number(int number)
  */
 int MSG_get_channel_number(void)
 {
  */
 int MSG_get_channel_number(void)
 {
-  xbt_assert0((msg_global)&&(msg_global->max_channel != 0), "Channel number not set yet!");
+  xbt_assert0((msg_global)
+             && (msg_global->max_channel != 0),
+             "Channel number not set yet!");
 
   return msg_global->max_channel;
 }
 
   return msg_global->max_channel;
 }
@@ -122,9 +127,9 @@ void __MSG_display_process_status(void)
 
 static void _XBT_CALL inthandler(int ignored)
 {
 
 static void _XBT_CALL inthandler(int ignored)
 {
-   INFO0("CTRL-C pressed. Displaying status and bailing out");
-   __MSG_display_process_status();
-   exit(1);
+  INFO0("CTRL-C pressed. Displaying status and bailing out");
+  __MSG_display_process_status();
+  exit(1);
 }
 
 /** \ingroup msg_simulation
 }
 
 /** \ingroup msg_simulation
@@ -132,46 +137,46 @@ static void _XBT_CALL inthandler(int ignored)
  */
 MSG_error_t MSG_main(void)
 {
  */
 MSG_error_t MSG_main(void)
 {
-       smx_cond_t cond = NULL;
-       smx_action_t smx_action;
-       xbt_fifo_t actions_done = xbt_fifo_new();
-       xbt_fifo_t actions_failed = xbt_fifo_new();
-
-       /* Prepare to display some more info when dying on Ctrl-C pressing */
-       signal(SIGINT,inthandler);
-
-       /* Clean IO before the run */
-       fflush(stdout);
-       fflush(stderr);
-
-       //surf_solve(); /* Takes traces into account. Returns 0.0 */
-       /* xbt_fifo_size(msg_global->process_to_run) */
-
-       while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
-
-               while ( (smx_action = xbt_fifo_pop(actions_failed)) ) {
-
-
-                       DEBUG1("** %s failed **",smx_action->name);
-                       while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
-                               SIMIX_cond_broadcast(cond);
-                       }
-                       /* action finished, destroy it */
-               //      SIMIX_action_destroy(smx_action);
-               }
-
-               while ( (smx_action = xbt_fifo_pop(actions_done)) ) {
-
-                       DEBUG1("** %s done **",smx_action->name);
-                       while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
-                               SIMIX_cond_broadcast(cond);
-                       }
-                       /* action finished, destroy it */
-                       //SIMIX_action_destroy(smx_action);
-               }
-       }
-       xbt_fifo_free(actions_failed);
-       xbt_fifo_free(actions_done);
+  smx_cond_t cond = NULL;
+  smx_action_t smx_action;
+  xbt_fifo_t actions_done = xbt_fifo_new();
+  xbt_fifo_t actions_failed = xbt_fifo_new();
+
+  /* Prepare to display some more info when dying on Ctrl-C pressing */
+  signal(SIGINT, inthandler);
+
+  /* Clean IO before the run */
+  fflush(stdout);
+  fflush(stderr);
+
+  //surf_solve(); /* Takes traces into account. Returns 0.0 */
+  /* xbt_fifo_size(msg_global->process_to_run) */
+
+  while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
+
+    while ((smx_action = xbt_fifo_pop(actions_failed))) {
+
+
+      DEBUG1("** %s failed **", smx_action->name);
+      while ((cond = xbt_fifo_pop(smx_action->cond_list))) {
+       SIMIX_cond_broadcast(cond);
+      }
+      /* action finished, destroy it */
+      //      SIMIX_action_destroy(smx_action);
+    }
+
+    while ((smx_action = xbt_fifo_pop(actions_done))) {
+
+      DEBUG1("** %s done **", smx_action->name);
+      while ((cond = xbt_fifo_pop(smx_action->cond_list))) {
+       SIMIX_cond_broadcast(cond);
+      }
+      /* action finished, destroy it */
+      //SIMIX_action_destroy(smx_action);
+    }
+  }
+  xbt_fifo_free(actions_failed);
+  xbt_fifo_free(actions_done);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -187,14 +192,15 @@ int MSG_process_killall(int reset_PIDs)
   m_process_t p = NULL;
   m_process_t self = MSG_process_self();
 
   m_process_t p = NULL;
   m_process_t self = MSG_process_self();
 
-  while((p=xbt_fifo_pop(msg_global->process_list))) {
-    if(p!=self) MSG_process_kill(p);
-  }    
+  while ((p = xbt_fifo_pop(msg_global->process_list))) {
+    if (p != self)
+      MSG_process_kill(p);
+  }
 
 
-  if(reset_PIDs>0) {
-    msg_global->PID = reset_PIDs;  
+  if (reset_PIDs > 0) {
+    msg_global->PID = reset_PIDs;
     msg_global->session++;
     msg_global->session++;
- }
 }
 
   return msg_global->PID;
 
 
   return msg_global->PID;
 
@@ -210,18 +216,18 @@ MSG_error_t MSG_clean(void)
   m_process_t p = NULL;
 
 
   m_process_t p = NULL;
 
 
-  while((p=xbt_fifo_pop(msg_global->process_list))) {
+  while ((p = xbt_fifo_pop(msg_global->process_list))) {
     MSG_process_kill(p);
   }
 
     MSG_process_kill(p);
   }
 
-  xbt_fifo_foreach(msg_global->host,i,h,m_host_t) {
+  xbt_fifo_foreach(msg_global->host, i, h, m_host_t) {
     __MSG_host_destroy(h);
   }
   xbt_fifo_free(msg_global->host);
   xbt_fifo_free(msg_global->process_list);
 
   free(msg_global);
     __MSG_host_destroy(h);
   }
   xbt_fifo_free(msg_global->host);
   xbt_fifo_free(msg_global->process_list);
 
   free(msg_global);
-       SIMIX_clean();
+  SIMIX_clean();
 
   return MSG_OK;
 }
 
   return MSG_OK;
 }
@@ -230,8 +236,7 @@ MSG_error_t MSG_clean(void)
 /** \ingroup msg_easier_life
  * \brief A clock (in second).
  */
 /** \ingroup msg_easier_life
  * \brief A clock (in second).
  */
-double MSG_get_clock(void) 
+double MSG_get_clock(void)
 {
 {
-       return SIMIX_get_clock();
+  return SIMIX_get_clock();
 }
 }
-
index d00b791..73967cd 100644 (file)
@@ -1,17 +1,18 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, "Logging specific to MSG (gos)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg,
+                               "Logging specific to MSG (gos)");
 
 /** \defgroup msg_gos_functions MSG Operating System Functions
  *  \brief This section describes the functions that can be used
 
 /** \defgroup msg_gos_functions MSG Operating System Functions
  *  \brief This section describes the functions that can be used
@@ -19,9 +20,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, "Logging specific to MSG (gos)");
  */
 
 static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
  */
 
 static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
-                                                       m_channel_t channel,
-                                                       double max_duration,
-                                                       m_host_t host)
+                                                         m_channel_t
+                                                         channel,
+                                                         double
+                                                         max_duration,
+                                                         m_host_t host)
 {
 
   m_process_t process = MSG_process_self();
 {
 
   m_process_t process = MSG_process_self();
@@ -32,123 +35,131 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
   int first_time = 1;
   xbt_fifo_item_t item = NULL;
 
   int first_time = 1;
   xbt_fifo_item_t item = NULL;
 
-       smx_cond_t cond = NULL;                 //conditional wait if the task isn't on the channel yet
+  smx_cond_t cond = NULL;      //conditional wait if the task isn't on the channel yet
 
   CHECK_HOST();
 
   CHECK_HOST();
-  xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
   /* Sanity check */
   /* Sanity check */
-  xbt_assert0(task,"Null pointer for the task\n");
+  xbt_assert0(task, "Null pointer for the task\n");
 
 
-  if (*task) 
-    CRITICAL0("MSG_task_get() was asked to write in a non empty task struct.");
+  if (*task)
+    CRITICAL0
+       ("MSG_task_get() was asked to write in a non empty task struct.");
 
   /* Get the task */
   h = MSG_host_self();
   h_simdata = h->simdata;
 
 
   /* Get the task */
   h = MSG_host_self();
   h_simdata = h->simdata;
 
-  DEBUG2("Waiting for a task on channel %d (%s)", channel,h->name);
+  DEBUG2("Waiting for a task on channel %d (%s)", channel, h->name);
 
 
-       SIMIX_mutex_lock(h->simdata->mutex);
+  SIMIX_mutex_lock(h->simdata->mutex);
   while (1) {
   while (1) {
-               if(xbt_fifo_size(h_simdata->mbox[channel])>0) {
-                       if(!host) {
-                               t = xbt_fifo_shift(h_simdata->mbox[channel]);
-                               break;
-                       } else {
-                               xbt_fifo_foreach(h->simdata->mbox[channel],item,t,m_task_t) {
-                                       if(t->simdata->source==host) break;
-                               }
-                               if(item) {
-                                       xbt_fifo_remove_item(h->simdata->mbox[channel],item);
-                                       break;
-                               } 
-                       }
-               }
-               
-               if(max_duration>0) {
-                       if(!first_time) {
-                               SIMIX_mutex_unlock(h->simdata->mutex);
-                               h_simdata->sleeping[channel] = NULL;
-                               SIMIX_cond_destroy(cond);
-                               MSG_RETURN(MSG_TRANSFER_FAILURE);
-                       }
-               }
-               xbt_assert1(!(h_simdata->sleeping[channel]),"A process is already blocked on channel %d", channel);
-       
-               cond = SIMIX_cond_init();
-               h_simdata->sleeping[channel] = cond;
-               if (max_duration > 0) {
-                       SIMIX_cond_wait_timeout(cond, h->simdata->mutex, max_duration);
-               }
-               else SIMIX_cond_wait(h_simdata->sleeping[channel],h->simdata->mutex);
-
-               if(SIMIX_host_get_state(h_simdata->s_host)==0)
-      MSG_RETURN(MSG_HOST_FAILURE);
-
-               first_time = 0;
+    if (xbt_fifo_size(h_simdata->mbox[channel]) > 0) {
+      if (!host) {
+       t = xbt_fifo_shift(h_simdata->mbox[channel]);
+       break;
+      } else {
+       xbt_fifo_foreach(h->simdata->mbox[channel], item, t, m_task_t) {
+         if (t->simdata->source == host)
+           break;
        }
        }
+       if (item) {
+         xbt_fifo_remove_item(h->simdata->mbox[channel], item);
+         break;
+       }
+      }
+    }
+
+    if (max_duration > 0) {
+      if (!first_time) {
        SIMIX_mutex_unlock(h->simdata->mutex);
        SIMIX_mutex_unlock(h->simdata->mutex);
+       h_simdata->sleeping[channel] = NULL;
+       SIMIX_cond_destroy(cond);
+       MSG_RETURN(MSG_TRANSFER_FAILURE);
+      }
+    }
+    xbt_assert1(!(h_simdata->sleeping[channel]),
+               "A process is already blocked on channel %d", channel);
+
+    cond = SIMIX_cond_init();
+    h_simdata->sleeping[channel] = cond;
+    if (max_duration > 0) {
+      SIMIX_cond_wait_timeout(cond, h->simdata->mutex, max_duration);
+    } else
+      SIMIX_cond_wait(h_simdata->sleeping[channel], h->simdata->mutex);
+
+    if (SIMIX_host_get_state(h_simdata->s_host) == 0)
+      MSG_RETURN(MSG_HOST_FAILURE);
+
+    first_time = 0;
+  }
+  SIMIX_mutex_unlock(h->simdata->mutex);
 
   DEBUG1("OK, got a task (%s)", t->name);
 
   DEBUG1("OK, got a task (%s)", t->name);
-       /* clean conditional */
-       if (cond) {
-               SIMIX_cond_destroy(cond);
-               h_simdata->sleeping[channel] = NULL;
-       }
+  /* clean conditional */
+  if (cond) {
+    SIMIX_cond_destroy(cond);
+    h_simdata->sleeping[channel] = NULL;
+  }
 
   t_simdata = t->simdata;
 
   t_simdata = t->simdata;
-       t_simdata->receiver = process;
-  *task=t;
+  t_simdata->receiver = process;
+  *task = t;
 
 
-       SIMIX_mutex_lock(t_simdata->mutex);
+  SIMIX_mutex_lock(t_simdata->mutex);
 
   /* Transfer */
   t_simdata->using++;
 
   /* Transfer */
   t_simdata->using++;
-       /* create SIMIX action to the communication */
-       t_simdata->comm = SIMIX_action_communicate(t_simdata->sender->simdata->m_host->simdata->s_host,
-                                                  process->simdata->m_host->simdata->s_host,t->name, t_simdata->message_size, 
-                                                  t_simdata->rate); 
-       /* if the process is suspend, create the action but stop its execution, it will be restart when the sender process resume */
-       if (MSG_process_is_suspended(t_simdata->sender)) {
-               DEBUG1("Process sender (%s) suspended", t_simdata->sender->name);
-               SIMIX_action_set_priority(t_simdata->comm,0);
-       }
-       process->simdata->waiting_task = t;
-       SIMIX_register_action_to_condition(t_simdata->comm, t_simdata->cond);
-       SIMIX_cond_wait(t_simdata->cond,t_simdata->mutex);
-       process->simdata->waiting_task = NULL;
-
-       /* the task has already finished and the pointer must be null*/
-       if (t->simdata->sender) {
-               t->simdata->sender->simdata->waiting_task = NULL;
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               //t->simdata->comm = NULL;
-               //t->simdata->compute = NULL;
-       }
-       /* for this process, don't need to change in get function*/
-       t->simdata->receiver = NULL;
-       SIMIX_mutex_unlock(t_simdata->mutex);
+  /* create SIMIX action to the communication */
+  t_simdata->comm =
+      SIMIX_action_communicate(t_simdata->sender->simdata->m_host->
+                              simdata->s_host,
+                              process->simdata->m_host->simdata->s_host,
+                              t->name, t_simdata->message_size,
+                              t_simdata->rate);
+  /* if the process is suspend, create the action but stop its execution, it will be restart when the sender process resume */
+  if (MSG_process_is_suspended(t_simdata->sender)) {
+    DEBUG1("Process sender (%s) suspended", t_simdata->sender->name);
+    SIMIX_action_set_priority(t_simdata->comm, 0);
+  }
+  process->simdata->waiting_task = t;
+  SIMIX_register_action_to_condition(t_simdata->comm, t_simdata->cond);
+  SIMIX_cond_wait(t_simdata->cond, t_simdata->mutex);
+  process->simdata->waiting_task = NULL;
+
+  /* the task has already finished and the pointer must be null */
+  if (t->simdata->sender) {
+    t->simdata->sender->simdata->waiting_task = NULL;
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    //t->simdata->comm = NULL;
+    //t->simdata->compute = NULL;
+  }
+  /* for this process, don't need to change in get function */
+  t->simdata->receiver = NULL;
+  SIMIX_mutex_unlock(t_simdata->mutex);
 
 
 
 
-       if(SIMIX_action_get_state(t_simdata->comm) == SURF_ACTION_DONE) {
-               //t_simdata->comm = NULL;
-               SIMIX_action_destroy(t_simdata->comm);
-               t_simdata->comm = NULL;
+  if (SIMIX_action_get_state(t_simdata->comm) == SURF_ACTION_DONE) {
+    //t_simdata->comm = NULL;
+    SIMIX_action_destroy(t_simdata->comm);
+    t_simdata->comm = NULL;
     MSG_RETURN(MSG_OK);
     MSG_RETURN(MSG_OK);
-       } else if (SIMIX_host_get_state(h_simdata->s_host)==0) {
-               //t_simdata->comm = NULL;
-               SIMIX_action_destroy(t_simdata->comm);
-               t_simdata->comm = NULL;
+  } else if (SIMIX_host_get_state(h_simdata->s_host) == 0) {
+    //t_simdata->comm = NULL;
+    SIMIX_action_destroy(t_simdata->comm);
+    t_simdata->comm = NULL;
     MSG_RETURN(MSG_HOST_FAILURE);
     MSG_RETURN(MSG_HOST_FAILURE);
-  } else { 
-               //t_simdata->comm = NULL;
-               SIMIX_action_destroy(t_simdata->comm);
-               t_simdata->comm = NULL;
+  } else {
+    //t_simdata->comm = NULL;
+    SIMIX_action_destroy(t_simdata->comm);
+    t_simdata->comm = NULL;
     MSG_RETURN(MSG_TRANSFER_FAILURE);
   }
 
 }
     MSG_RETURN(MSG_TRANSFER_FAILURE);
   }
 
 }
-       
+
 /** \ingroup msg_gos_functions
  * \brief Listen on a channel and wait for receiving a task.
  *
 /** \ingroup msg_gos_functions
  * \brief Listen on a channel and wait for receiving a task.
  *
@@ -163,8 +174,7 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
  * \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
  * if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
  */
  * \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
  * if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
  */
-MSG_error_t MSG_task_get(m_task_t * task,
-                        m_channel_t channel)
+MSG_error_t MSG_task_get(m_task_t * task, m_channel_t channel)
 {
   return MSG_task_get_with_time_out(task, channel, -1);
 }
 {
   return MSG_task_get_with_time_out(task, channel, -1);
 }
@@ -191,7 +201,8 @@ MSG_error_t MSG_task_get_with_time_out(m_task_t * task,
                                       m_channel_t channel,
                                       double max_duration)
 {
                                       m_channel_t channel,
                                       double max_duration)
 {
-  return __MSG_task_get_with_time_out_from_host(task, channel, max_duration, NULL);
+  return __MSG_task_get_with_time_out_from_host(task, channel,
+                                               max_duration, NULL);
 }
 
 /** \ingroup msg_gos_functions
 }
 
 /** \ingroup msg_gos_functions
@@ -209,7 +220,7 @@ MSG_error_t MSG_task_get_with_time_out(m_task_t * task,
  * \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
    if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
  */
  * \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
    if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
  */
-MSG_error_t MSG_task_get_from_host(m_task_t * task, int channel, 
+MSG_error_t MSG_task_get_from_host(m_task_t * task, int channel,
                                   m_host_t host)
 {
   return __MSG_task_get_with_time_out_from_host(task, channel, -1, host);
                                   m_host_t host)
 {
   return __MSG_task_get_with_time_out_from_host(task, channel, -1, host);
@@ -228,13 +239,15 @@ int MSG_task_Iprobe(m_channel_t channel)
 {
   m_host_t h = NULL;
 
 {
   m_host_t h = NULL;
 
-  xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
   CHECK_HOST();
 
   CHECK_HOST();
 
-  DEBUG2("Probing on channel %d (%s)", channel,h->name);
+  DEBUG2("Probing on channel %d (%s)", channel, h->name);
 
   h = MSG_host_self();
 
   h = MSG_host_self();
-  return(xbt_fifo_get_first_item(h->simdata->mbox[channel])!=NULL);
+  return (xbt_fifo_get_first_item(h->simdata->mbox[channel]) != NULL);
 }
 
 /** \ingroup msg_gos_functions
 }
 
 /** \ingroup msg_gos_functions
@@ -252,17 +265,19 @@ int MSG_task_probe_from(m_channel_t channel)
   xbt_fifo_item_t item;
   m_task_t t;
 
   xbt_fifo_item_t item;
   m_task_t t;
 
-  xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
   CHECK_HOST();
 
   h = MSG_host_self();
 
   CHECK_HOST();
 
   h = MSG_host_self();
 
-  DEBUG2("Probing on channel %d (%s)", channel,h->name);
-   
+  DEBUG2("Probing on channel %d (%s)", channel, h->name);
+
   item = xbt_fifo_get_first_item(h->simdata->mbox[channel]);
   item = xbt_fifo_get_first_item(h->simdata->mbox[channel]);
-  if ( (!item) || (!(t = xbt_fifo_get_item_content(item))) )
+  if ((!item) || (!(t = xbt_fifo_get_item_content(item))))
     return -1;
     return -1;
-   
+
   return MSG_process_get_PID(t->simdata->sender);
 }
 
   return MSG_process_get_PID(t->simdata->sender);
 }
 
@@ -282,62 +297,65 @@ int MSG_task_probe_from(m_channel_t channel)
  * \return #MSG_HOST_FAILURE if the host is shut down in the meantime
    and #MSG_OK otherwise.
  */
  * \return #MSG_HOST_FAILURE if the host is shut down in the meantime
    and #MSG_OK otherwise.
  */
-MSG_error_t MSG_channel_select_from(m_channel_t channel, double max_duration,
-               int *PID)
+MSG_error_t MSG_channel_select_from(m_channel_t channel,
+                                   double max_duration, int *PID)
 {
 {
-       m_host_t h = NULL;
-       simdata_host_t h_simdata = NULL;
-       xbt_fifo_item_t item;
-       m_task_t t;
-       int first_time = 1;
-       smx_cond_t cond;
-
-       xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
-       if(PID) {
-               *PID = -1;
-       }
+  m_host_t h = NULL;
+  simdata_host_t h_simdata = NULL;
+  xbt_fifo_item_t item;
+  m_task_t t;
+  int first_time = 1;
+  smx_cond_t cond;
 
 
-       if(max_duration==0.0) {
-               *PID = MSG_task_probe_from(channel);
-               MSG_RETURN(MSG_OK);
-       } else {
-               CHECK_HOST();
-               h = MSG_host_self();
-               h_simdata = h->simdata;
-
-               DEBUG2("Probing on channel %d (%s)", channel,h->name);
-               while(!(item = xbt_fifo_get_first_item(h->simdata->mbox[channel]))) {
-                       if(max_duration>0) {
-                               if(!first_time) {
-                                       MSG_RETURN(MSG_OK);
-                               }
-                       }
-                       SIMIX_mutex_lock(h_simdata->mutex);
-                       xbt_assert1(!(h_simdata->sleeping[channel]),
-                                       "A process is already blocked on this channel %d", channel);
-                       cond = SIMIX_cond_init();
-                       h_simdata->sleeping[channel] = cond; /* I'm waiting. Wake me up when you're ready */
-                       if(max_duration>0) {
-                               SIMIX_cond_wait_timeout(cond,h_simdata->mutex, max_duration);
-                       } else {
-                               SIMIX_cond_wait(cond,h_simdata->mutex);
-                       }
-                       SIMIX_cond_destroy(cond);
-                       SIMIX_mutex_unlock(h_simdata->mutex);
-                       if(SIMIX_host_get_state(h_simdata->s_host)==0) {
-                               MSG_RETURN(MSG_HOST_FAILURE);
-                       }
-                       h_simdata->sleeping[channel] = NULL;
-                       first_time = 0;
-               }
-               if (!item || !(t = xbt_fifo_get_item_content(item))) {
-                       MSG_RETURN(MSG_OK);
-               }
-               if(PID) {
-                       *PID = MSG_process_get_PID(t->simdata->sender);
-               }
-               MSG_RETURN(MSG_OK);
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
+  if (PID) {
+    *PID = -1;
+  }
+
+  if (max_duration == 0.0) {
+    *PID = MSG_task_probe_from(channel);
+    MSG_RETURN(MSG_OK);
+  } else {
+    CHECK_HOST();
+    h = MSG_host_self();
+    h_simdata = h->simdata;
+
+    DEBUG2("Probing on channel %d (%s)", channel, h->name);
+    while (!(item = xbt_fifo_get_first_item(h->simdata->mbox[channel]))) {
+      if (max_duration > 0) {
+       if (!first_time) {
+         MSG_RETURN(MSG_OK);
        }
        }
+      }
+      SIMIX_mutex_lock(h_simdata->mutex);
+      xbt_assert1(!(h_simdata->sleeping[channel]),
+                 "A process is already blocked on this channel %d",
+                 channel);
+      cond = SIMIX_cond_init();
+      h_simdata->sleeping[channel] = cond;     /* I'm waiting. Wake me up when you're ready */
+      if (max_duration > 0) {
+       SIMIX_cond_wait_timeout(cond, h_simdata->mutex, max_duration);
+      } else {
+       SIMIX_cond_wait(cond, h_simdata->mutex);
+      }
+      SIMIX_cond_destroy(cond);
+      SIMIX_mutex_unlock(h_simdata->mutex);
+      if (SIMIX_host_get_state(h_simdata->s_host) == 0) {
+       MSG_RETURN(MSG_HOST_FAILURE);
+      }
+      h_simdata->sleeping[channel] = NULL;
+      first_time = 0;
+    }
+    if (!item || !(t = xbt_fifo_get_item_content(item))) {
+      MSG_RETURN(MSG_OK);
+    }
+    if (PID) {
+      *PID = MSG_process_get_PID(t->simdata->sender);
+    }
+    MSG_RETURN(MSG_OK);
+  }
 }
 
 
 }
 
 
@@ -360,17 +378,20 @@ int MSG_task_probe_from_host(int channel, m_host_t host)
   m_task_t t;
   int count = 0;
   m_host_t h = NULL;
   m_task_t t;
   int count = 0;
   m_host_t h = NULL;
-  
-  xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
+
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
   CHECK_HOST();
   h = MSG_host_self();
 
   CHECK_HOST();
   h = MSG_host_self();
 
-  DEBUG2("Probing on channel %d (%s)", channel,h->name);
-   
-  xbt_fifo_foreach(h->simdata->mbox[channel],item,t,m_task_t) {
-    if(t->simdata->source==host) count++;
+  DEBUG2("Probing on channel %d (%s)", channel, h->name);
+
+  xbt_fifo_foreach(h->simdata->mbox[channel], item, t, m_task_t) {
+    if (t->simdata->source == host)
+      count++;
   }
   }
-   
+
   return count;
 }
 
   return count;
 }
 
@@ -403,8 +424,9 @@ int MSG_task_probe_from_host(int channel, m_host_t host)
    #MSG_TRANSFER_FAILURE if the transfer could not be properly done
    (network failure, dest failure, timeout...)
  */
    #MSG_TRANSFER_FAILURE if the transfer could not be properly done
    (network failure, dest failure, timeout...)
  */
-MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest, 
-                                     m_channel_t channel, double max_duration)
+MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest,
+                                     m_channel_t channel,
+                                     double max_duration)
 {
 
 
 {
 
 
@@ -414,76 +436,79 @@ MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest,
   m_host_t remote_host = NULL;
   CHECK_HOST();
 
   m_host_t remote_host = NULL;
   CHECK_HOST();
 
-  xbt_assert1((channel>=0) && (channel < msg_global->max_channel),"Invalid channel %d",channel);
+  xbt_assert1((channel >= 0)
+             && (channel < msg_global->max_channel), "Invalid channel %d",
+             channel);
 
   task_simdata = task->simdata;
   task_simdata->sender = process;
   task_simdata->source = MSG_process_get_host(process);
 
   task_simdata = task->simdata;
   task_simdata->sender = process;
   task_simdata->source = MSG_process_get_host(process);
-  xbt_assert0(task_simdata->using==1,
+  xbt_assert0(task_simdata->using == 1,
              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
   task_simdata->comm = NULL;
              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
   task_simdata->comm = NULL;
-  
+
   local_host = ((simdata_process_t) process->simdata)->m_host;
   remote_host = dest;
 
   local_host = ((simdata_process_t) process->simdata)->m_host;
   remote_host = dest;
 
-  DEBUG4("Trying to send a task (%g kB) from %s to %s on channel %d", 
-        task->simdata->message_size/1000,local_host->name, remote_host->name, channel);
+  DEBUG4("Trying to send a task (%g kB) from %s to %s on channel %d",
+        task->simdata->message_size / 1000, local_host->name,
+        remote_host->name, channel);
 
 
-       SIMIX_mutex_lock(remote_host->simdata->mutex);
+  SIMIX_mutex_lock(remote_host->simdata->mutex);
   xbt_fifo_push(((simdata_host_t) remote_host->simdata)->
                mbox[channel], task);
 
   xbt_fifo_push(((simdata_host_t) remote_host->simdata)->
                mbox[channel], task);
 
-  
-  if(remote_host->simdata->sleeping[channel]) {
+
+  if (remote_host->simdata->sleeping[channel]) {
     DEBUG0("Somebody is listening. Let's wake him up!");
     DEBUG0("Somebody is listening. Let's wake him up!");
-               SIMIX_cond_signal(remote_host->simdata->sleeping[channel]);
+    SIMIX_cond_signal(remote_host->simdata->sleeping[channel]);
   }
   }
-       SIMIX_mutex_unlock(remote_host->simdata->mutex);
+  SIMIX_mutex_unlock(remote_host->simdata->mutex);
 
   process->simdata->put_host = dest;
   process->simdata->put_channel = channel;
 
   process->simdata->put_host = dest;
   process->simdata->put_channel = channel;
-       SIMIX_mutex_lock(task->simdata->mutex);
- // DEBUG4("Task sent (%g kB) from %s to %s on channel %d, waiting...", task->simdata->message_size/1000,local_host->name, remote_host->name, channel);
-
-       process->simdata->waiting_task = task;
-       if (max_duration >0) {
-               SIMIX_cond_wait_timeout(task->simdata->cond,task->simdata->mutex,max_duration);
-               /* verify if the timeout happened and the communication didn't started yet */
-               if (task->simdata->comm==NULL) {
-                       task->simdata->using--;
-                       process->simdata->waiting_task = NULL;
-                       xbt_fifo_remove(((simdata_host_t) remote_host->simdata)->mbox[channel],
-                       task);
-                       if (task->simdata->receiver) {
-                               task->simdata->receiver->simdata->waiting_task = NULL;
-                       }
-                       task->simdata->sender = NULL;
-                       SIMIX_mutex_unlock(task->simdata->mutex);
-                       MSG_RETURN(MSG_TRANSFER_FAILURE);
-               }
-       }
-       else {
-               SIMIX_cond_wait(task->simdata->cond,task->simdata->mutex);
-       }
+  SIMIX_mutex_lock(task->simdata->mutex);
 // DEBUG4("Task sent (%g kB) from %s to %s on channel %d, waiting...", task->simdata->message_size/1000,local_host->name, remote_host->name, channel);
+
+  process->simdata->waiting_task = task;
+  if (max_duration > 0) {
+    SIMIX_cond_wait_timeout(task->simdata->cond, task->simdata->mutex,
+                           max_duration);
+    /* verify if the timeout happened and the communication didn't started yet */
+    if (task->simdata->comm == NULL) {
+      task->simdata->using--;
+      process->simdata->waiting_task = NULL;
+      xbt_fifo_remove(((simdata_host_t) remote_host->simdata)->
+                     mbox[channel], task);
+      if (task->simdata->receiver) {
+       task->simdata->receiver->simdata->waiting_task = NULL;
+      }
+      task->simdata->sender = NULL;
+      SIMIX_mutex_unlock(task->simdata->mutex);
+      MSG_RETURN(MSG_TRANSFER_FAILURE);
+    }
+  } else {
+    SIMIX_cond_wait(task->simdata->cond, task->simdata->mutex);
+  }
 
 
-       DEBUG1("Action terminated %s",task->name);    
-       task->simdata->using--;
-       process->simdata->waiting_task = NULL;
-       /* the task has already finished and the pointer must be null*/
-       if (task->simdata->receiver) {
-               task->simdata->receiver->simdata->waiting_task = NULL;
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-       //      task->simdata->comm = NULL;
-               //task->simdata->compute = NULL;
-       }
-       task->simdata->sender = NULL;
-       SIMIX_mutex_unlock(task->simdata->mutex);
+  DEBUG1("Action terminated %s", task->name);
+  task->simdata->using--;
+  process->simdata->waiting_task = NULL;
+  /* the task has already finished and the pointer must be null */
+  if (task->simdata->receiver) {
+    task->simdata->receiver->simdata->waiting_task = NULL;
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    //      task->simdata->comm = NULL;
+    //task->simdata->compute = NULL;
+  }
+  task->simdata->sender = NULL;
+  SIMIX_mutex_unlock(task->simdata->mutex);
 
 
-       if(SIMIX_action_get_state(task->simdata->comm) == SURF_ACTION_DONE) {
+  if (SIMIX_action_get_state(task->simdata->comm) == SURF_ACTION_DONE) {
     MSG_RETURN(MSG_OK);
     MSG_RETURN(MSG_OK);
-       } else if (SIMIX_host_get_state(local_host->simdata->s_host)==0) {
+  } else if (SIMIX_host_get_state(local_host->simdata->s_host) == 0) {
     MSG_RETURN(MSG_HOST_FAILURE);
     MSG_RETURN(MSG_HOST_FAILURE);
-  } else { 
+  } else {
     MSG_RETURN(MSG_TRANSFER_FAILURE);
   }
 }
     MSG_RETURN(MSG_TRANSFER_FAILURE);
   }
 }
@@ -514,8 +539,7 @@ MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest,
  * #MSG_TRANSFER_FAILURE if the transfer could not be properly done
  * (network failure, dest failure)
  */
  * #MSG_TRANSFER_FAILURE if the transfer could not be properly done
  * (network failure, dest failure)
  */
-MSG_error_t MSG_task_put(m_task_t task,
-                        m_host_t dest, m_channel_t channel)
+MSG_error_t MSG_task_put(m_task_t task, m_host_t dest, m_channel_t channel)
 {
   return MSG_task_put_with_timeout(task, dest, channel, -1.0);
 }
 {
   return MSG_task_put_with_timeout(task, dest, channel, -1.0);
 }
@@ -531,9 +555,9 @@ MSG_error_t MSG_task_put_bounded(m_task_t task,
                                 double max_rate)
 {
   MSG_error_t res = MSG_OK;
                                 double max_rate)
 {
   MSG_error_t res = MSG_OK;
-  task->simdata->rate=max_rate;
+  task->simdata->rate = max_rate;
   res = MSG_task_put(task, dest, channel);
   res = MSG_task_put(task, dest, channel);
-  return(res);
+  return (res);
 }
 
 /** \ingroup msg_gos_functions
 }
 
 /** \ingroup msg_gos_functions
@@ -548,46 +572,48 @@ MSG_error_t MSG_task_put_bounded(m_task_t task,
  */
 MSG_error_t MSG_task_execute(m_task_t task)
 {
  */
 MSG_error_t MSG_task_execute(m_task_t task)
 {
-       simdata_task_t simdata = NULL;
-       m_process_t self = MSG_process_self();
+  simdata_task_t simdata = NULL;
+  m_process_t self = MSG_process_self();
   CHECK_HOST();
 
   simdata = task->simdata;
   CHECK_HOST();
 
   simdata = task->simdata;
-  xbt_assert0((!simdata->compute)&&(task->simdata->using==1),
+  xbt_assert0((!simdata->compute) && (task->simdata->using == 1),
              "This task is executed somewhere else. Go fix your code!");
              "This task is executed somewhere else. Go fix your code!");
-       
-       DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
-  simdata->using++;
-       SIMIX_mutex_lock(simdata->mutex);
-  simdata->compute = SIMIX_action_execute(SIMIX_host_self(), task->name, simdata->computation_amount);
-       SIMIX_action_set_priority(simdata->compute, simdata->priority);
-
-       self->simdata->waiting_task = task;
-       SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
-       SIMIX_cond_wait(simdata->cond, simdata->mutex);
-       self->simdata->waiting_task = NULL;
 
 
-       SIMIX_mutex_unlock(simdata->mutex);
+  DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
+  simdata->using++;
+  SIMIX_mutex_lock(simdata->mutex);
+  simdata->compute =
+      SIMIX_action_execute(SIMIX_host_self(), task->name,
+                          simdata->computation_amount);
+  SIMIX_action_set_priority(simdata->compute, simdata->priority);
+
+  self->simdata->waiting_task = task;
+  SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
+  SIMIX_cond_wait(simdata->cond, simdata->mutex);
+  self->simdata->waiting_task = NULL;
+
+  SIMIX_mutex_unlock(simdata->mutex);
   simdata->using--;
 
   simdata->using--;
 
-       if(SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->computation_amount = 0.0;
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->computation_amount = 0.0;
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_OK);
     MSG_RETURN(MSG_OK);
-       } else if (SIMIX_host_get_state(SIMIX_host_self())==0) {
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_HOST_FAILURE);
     MSG_RETURN(MSG_HOST_FAILURE);
-  } else { 
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  } else {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_TASK_CANCELLED);
   }
 }
     MSG_RETURN(MSG_TASK_CANCELLED);
   }
 }
@@ -612,16 +638,15 @@ MSG_error_t MSG_task_execute(m_task_t task)
  * \see m_task_t
  * \return The new corresponding object.
  */
  * \see m_task_t
  * \return The new corresponding object.
  */
-m_task_t MSG_parallel_task_create(const char *name, 
+m_task_t MSG_parallel_task_create(const char *name,
                                  int host_nb,
                                  int host_nb,
-                                 const m_host_t *host_list,
+                                 const m_host_t * host_list,
                                  double *computation_amount,
                                  double *computation_amount,
-                                 double *communication_amount,
-                                 void *data)
+                                 double *communication_amount, void *data)
 {
   int i;
 {
   int i;
-  simdata_task_t simdata = xbt_new0(s_simdata_task_t,1);
-  m_task_t task = xbt_new0(s_m_task_t,1);
+  simdata_task_t simdata = xbt_new0(s_simdata_task_t, 1);
+  m_task_t task = xbt_new0(s_m_task_t, 1);
   task->simdata = simdata;
 
   /* Task structure */
   task->simdata = simdata;
 
   /* Task structure */
@@ -631,10 +656,10 @@ m_task_t MSG_parallel_task_create(const char *name,
   /* Simulator Data */
   simdata->computation_amount = 0;
   simdata->message_size = 0;
   /* Simulator Data */
   simdata->computation_amount = 0;
   simdata->message_size = 0;
-       simdata->cond = SIMIX_cond_init();
-       simdata->mutex = SIMIX_mutex_init();
-       simdata->compute = NULL;
-       simdata->comm = NULL;
+  simdata->cond = SIMIX_cond_init();
+  simdata->mutex = SIMIX_mutex_init();
+  simdata->compute = NULL;
+  simdata->comm = NULL;
   simdata->rate = -1.0;
   simdata->using = 1;
   simdata->sender = NULL;
   simdata->rate = -1.0;
   simdata->using = 1;
   simdata->sender = NULL;
@@ -646,7 +671,7 @@ m_task_t MSG_parallel_task_create(const char *name,
   simdata->comp_amount = computation_amount;
   simdata->comm_amount = communication_amount;
 
   simdata->comp_amount = computation_amount;
   simdata->comm_amount = communication_amount;
 
-  for(i=0;i<host_nb;i++)
+  for (i = 0; i < host_nb; i++)
     simdata->host_list[i] = host_list[i]->simdata->s_host;
 
   return task;
     simdata->host_list[i] = host_list[i]->simdata->s_host;
 
   return task;
@@ -656,50 +681,55 @@ m_task_t MSG_parallel_task_create(const char *name,
 
 MSG_error_t MSG_parallel_task_execute(m_task_t task)
 {
 
 MSG_error_t MSG_parallel_task_execute(m_task_t task)
 {
-       simdata_task_t simdata = NULL;
-       m_process_t self = MSG_process_self();
+  simdata_task_t simdata = NULL;
+  m_process_t self = MSG_process_self();
   CHECK_HOST();
 
   simdata = task->simdata;
   CHECK_HOST();
 
   simdata = task->simdata;
-  xbt_assert0((!simdata->compute)&&(task->simdata->using==1),
+  xbt_assert0((!simdata->compute) && (task->simdata->using == 1),
              "This task is executed somewhere else. Go fix your code!");
 
              "This task is executed somewhere else. Go fix your code!");
 
-  xbt_assert0(simdata->host_nb,"This is not a parallel task. Go to hell.");
-       
-       DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
+  xbt_assert0(simdata->host_nb,
+             "This is not a parallel task. Go to hell.");
+
+  DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
   simdata->using++;
   simdata->using++;
-       SIMIX_mutex_lock(simdata->mutex);
-  simdata->compute = SIMIX_action_parallel_execute(task->name, simdata->host_nb, simdata->host_list, simdata->comp_amount, simdata->comm_amount, 1.0, -1.0);
+  SIMIX_mutex_lock(simdata->mutex);
+  simdata->compute =
+      SIMIX_action_parallel_execute(task->name, simdata->host_nb,
+                                   simdata->host_list,
+                                   simdata->comp_amount,
+                                   simdata->comm_amount, 1.0, -1.0);
 
 
-       self->simdata->waiting_task = task;
-       SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
-       SIMIX_cond_wait(simdata->cond, simdata->mutex);
-       self->simdata->waiting_task = NULL;
+  self->simdata->waiting_task = task;
+  SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
+  SIMIX_cond_wait(simdata->cond, simdata->mutex);
+  self->simdata->waiting_task = NULL;
 
 
 
 
-       SIMIX_mutex_unlock(simdata->mutex);
+  SIMIX_mutex_unlock(simdata->mutex);
   simdata->using--;
 
   simdata->using--;
 
-       if(SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->computation_amount = 0.0;
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->computation_amount = 0.0;
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_OK);
     MSG_RETURN(MSG_OK);
-       } else if (SIMIX_host_get_state(SIMIX_host_self())==0) {
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_HOST_FAILURE);
     MSG_RETURN(MSG_HOST_FAILURE);
-  } else { 
-               /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
-               SIMIX_action_destroy(task->simdata->compute);
-               simdata->comm = NULL;
-               simdata->compute = NULL;
+  } else {
+    /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+    SIMIX_action_destroy(task->simdata->compute);
+    simdata->comm = NULL;
+    simdata->compute = NULL;
     MSG_RETURN(MSG_TASK_CANCELLED);
     MSG_RETURN(MSG_TASK_CANCELLED);
-  }    
+  }
 
 }
 
 
 }
 
@@ -713,49 +743,50 @@ MSG_error_t MSG_parallel_task_execute(m_task_t task)
  */
 MSG_error_t MSG_process_sleep(double nb_sec)
 {
  */
 MSG_error_t MSG_process_sleep(double nb_sec)
 {
-       smx_action_t act_sleep;
-       m_process_t proc = MSG_process_self();
-       smx_mutex_t mutex;
-       smx_cond_t cond;
-       /* create action to sleep */
-       act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->s_process),nb_sec);
-       
-       mutex = SIMIX_mutex_init();
-       SIMIX_mutex_lock(mutex);
-       /* create conditional and register action to it */
-       cond = SIMIX_cond_init();
-
-       SIMIX_register_action_to_condition(act_sleep, cond);
-       SIMIX_cond_wait(cond,mutex);
-       SIMIX_mutex_unlock(mutex);
-
-       /* remove variables */
-       SIMIX_cond_destroy(cond);
-       SIMIX_mutex_destroy(mutex);
-
-  if(SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
-    if(SIMIX_host_get_state(SIMIX_host_self()) == SURF_CPU_OFF) {
-                       SIMIX_action_destroy(act_sleep);
+  smx_action_t act_sleep;
+  m_process_t proc = MSG_process_self();
+  smx_mutex_t mutex;
+  smx_cond_t cond;
+  /* create action to sleep */
+  act_sleep =
+      SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->s_process),
+                        nb_sec);
+
+  mutex = SIMIX_mutex_init();
+  SIMIX_mutex_lock(mutex);
+  /* create conditional and register action to it */
+  cond = SIMIX_cond_init();
+
+  SIMIX_register_action_to_condition(act_sleep, cond);
+  SIMIX_cond_wait(cond, mutex);
+  SIMIX_mutex_unlock(mutex);
+
+  /* remove variables */
+  SIMIX_cond_destroy(cond);
+  SIMIX_mutex_destroy(mutex);
+
+  if (SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
+    if (SIMIX_host_get_state(SIMIX_host_self()) == SURF_CPU_OFF) {
+      SIMIX_action_destroy(act_sleep);
       MSG_RETURN(MSG_HOST_FAILURE);
     }
       MSG_RETURN(MSG_HOST_FAILURE);
     }
+  } else {
+    SIMIX_action_destroy(act_sleep);
+    MSG_RETURN(MSG_HOST_FAILURE);
   }
   }
-       else {
-               SIMIX_action_destroy(act_sleep);
-               MSG_RETURN(MSG_HOST_FAILURE);
-       }
 
 
 
 
-       MSG_RETURN(MSG_OK);
+  MSG_RETURN(MSG_OK);
 }
 
 /** \ingroup msg_gos_functions
  * \brief Return the number of MSG tasks currently running on
  * the host of the current running process.
  */
 }
 
 /** \ingroup msg_gos_functions
  * \brief Return the number of MSG tasks currently running on
  * the host of the current running process.
  */
-static int MSG_get_msgload(void) 
+static int MSG_get_msgload(void)
 {
 {
-       xbt_die("not implemented yet");
-       return 0;
+  xbt_die("not implemented yet");
+  return 0;
 }
 
 /** \ingroup msg_gos_functions
 }
 
 /** \ingroup msg_gos_functions
index 2d700c4..f8f9cdf 100644 (file)
@@ -1,12 +1,12 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 /********************************* Host **************************************/
 m_host_t __MSG_host_create(smx_host_t workstation, void *data)
 {
 /********************************* Host **************************************/
 m_host_t __MSG_host_create(smx_host_t workstation, void *data)
 {
-       const char * name;
-  simdata_host_t simdata = xbt_new0(s_simdata_host_t,1);
-  m_host_t host = xbt_new0(s_m_host_t,1);
+  const char *name;
+  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
+  m_host_t host = xbt_new0(s_m_host_t, 1);
   int i;
 
   int i;
 
-       name = SIMIX_host_get_name(workstation);
+  name = SIMIX_host_get_name(workstation);
   /* Host structure */
   host->name = xbt_strdup(name);
   host->simdata = simdata;
   /* Host structure */
   host->name = xbt_strdup(name);
   host->simdata = simdata;
@@ -46,14 +46,14 @@ m_host_t __MSG_host_create(smx_host_t workstation, void *data)
   simdata->mbox = xbt_new0(xbt_fifo_t, msg_global->max_channel);
   for (i = 0; i < msg_global->max_channel; i++)
     simdata->mbox[i] = xbt_fifo_new();
   simdata->mbox = xbt_new0(xbt_fifo_t, msg_global->max_channel);
   for (i = 0; i < msg_global->max_channel; i++)
     simdata->mbox[i] = xbt_fifo_new();
-  
-       simdata->sleeping = xbt_new0(smx_cond_t, msg_global->max_channel);
-       simdata->mutex = SIMIX_mutex_init();
-       SIMIX_host_set_data(workstation, host);
+
+  simdata->sleeping = xbt_new0(smx_cond_t, msg_global->max_channel);
+  simdata->mutex = SIMIX_mutex_init();
+  SIMIX_host_set_data(workstation, host);
 
   /* Update global variables */
 
   /* Update global variables */
-       xbt_fifo_unshift(msg_global->host, host);
+  xbt_fifo_unshift(msg_global->host, host);
+
   return host;
 }
 
   return host;
 }
 
@@ -65,8 +65,8 @@ m_host_t __MSG_host_create(smx_host_t workstation, void *data)
    or not and attach \a data to \a host if it is possible.
  */
 MSG_error_t MSG_host_set_data(m_host_t host, void *data)
    or not and attach \a data to \a host if it is possible.
  */
 MSG_error_t MSG_host_set_data(m_host_t host, void *data)
-{      
-  xbt_assert0((host!=NULL), "Invalid parameters");
+{
+  xbt_assert0((host != NULL), "Invalid parameters");
   xbt_assert0((host->data == NULL), "Data already set");
 
   /* Assign data */
   xbt_assert0((host->data == NULL), "Data already set");
 
   /* Assign data */
@@ -101,7 +101,8 @@ void *MSG_host_get_data(m_host_t host)
 const char *MSG_host_get_name(m_host_t host)
 {
 
 const char *MSG_host_get_name(m_host_t host)
 {
 
-  xbt_assert0((host != NULL) && (host->simdata != NULL), "Invalid parameters");
+  xbt_assert0((host != NULL)
+             && (host->simdata != NULL), "Invalid parameters");
 
   /* Return data */
   return (host->name);
 
   /* Return data */
   return (host->name);
@@ -129,14 +130,14 @@ void __MSG_host_destroy(m_host_t host)
   xbt_assert0((host != NULL), "Invalid parameters");
 
   /* Clean Simulator data */
   xbt_assert0((host != NULL), "Invalid parameters");
 
   /* Clean Simulator data */
-   /* SIMIX host will be cleaned when MSG_clean calls SIMIX_clean */
+  /* SIMIX host will be cleaned when MSG_clean calls SIMIX_clean */
   simdata = (host)->simdata;
 
   for (i = 0; i < msg_global->max_channel; i++)
     xbt_fifo_free(simdata->mbox[i]);
   free(simdata->mbox);
   free(simdata->sleeping);
   simdata = (host)->simdata;
 
   for (i = 0; i < msg_global->max_channel; i++)
     xbt_fifo_free(simdata->mbox[i]);
   free(simdata->mbox);
   free(simdata->sleeping);
-       SIMIX_mutex_destroy(simdata->mutex);
+  SIMIX_mutex_destroy(simdata->mutex);
   free(simdata);
 
   /* Clean host structure */
   free(simdata);
 
   /* Clean host structure */
@@ -159,7 +160,7 @@ int MSG_get_host_number(void)
  */
 m_host_t *MSG_get_host_table(void)
 {
  */
 m_host_t *MSG_get_host_table(void)
 {
-  return ((m_host_t *)xbt_fifo_to_array(msg_global->host));
+  return ((m_host_t *) xbt_fifo_to_array(msg_global->host));
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -168,10 +169,10 @@ m_host_t *MSG_get_host_table(void)
  */
 int MSG_get_host_msgload(m_host_t h)
 {
  */
 int MSG_get_host_msgload(m_host_t h)
 {
-  xbt_assert0((h!= NULL), "Invalid parameters");
+  xbt_assert0((h != NULL), "Invalid parameters");
   xbt_assert0(0, "Not implemented yet");
 
   xbt_assert0(0, "Not implemented yet");
 
-  return(0);
+  return (0);
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -180,9 +181,9 @@ int MSG_get_host_msgload(m_host_t h)
  */
 double MSG_get_host_speed(m_host_t h)
 {
  */
 double MSG_get_host_speed(m_host_t h)
 {
-  xbt_assert0((h!= NULL), "Invalid parameters");
+  xbt_assert0((h != NULL), "Invalid parameters");
 
 
-  return(SIMIX_host_get_speed(h->simdata->s_host));
+  return (SIMIX_host_get_speed(h->simdata->s_host));
 }
 
 /** \ingroup msg_gos_functions
 }
 
 /** \ingroup msg_gos_functions
@@ -190,8 +191,8 @@ double MSG_get_host_speed(m_host_t h)
  *
  * \param h host to test
  */
  *
  * \param h host to test
  */
-int MSG_host_is_avail (m_host_t h)
+int MSG_host_is_avail(m_host_t h)
 {
 {
-  xbt_assert0((h!= NULL), "Invalid parameters");
-       return (SIMIX_host_get_state(h->simdata->s_host));
+  xbt_assert0((h != NULL), "Invalid parameters");
+  return (SIMIX_host_get_state(h->simdata->s_host));
 }
 }
index baf3316..34afa54 100644 (file)
@@ -1,17 +1,18 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (process)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg,
+                               "Logging specific to MSG (process)");
 
 /** \defgroup m_process_management Management Functions of Agents
  *  \brief This section describes the agent structure of MSG
 
 /** \defgroup m_process_management Management Functions of Agents
  *  \brief This section describes the agent structure of MSG
@@ -39,31 +40,33 @@ m_process_t MSG_process_create(const char *name,
                               xbt_main_func_t code, void *data,
                               m_host_t host)
 {
                               xbt_main_func_t code, void *data,
                               m_host_t host)
 {
-  return MSG_process_create_with_arguments(name, code, data, host, -1, NULL);
+  return MSG_process_create_with_arguments(name, code, data, host, -1,
+                                          NULL);
 }
 
 void __MSG_process_cleanup(void *arg)
 {
 }
 
 void __MSG_process_cleanup(void *arg)
 {
-       /* arg is a pointer to a simix process, we can get the msg process with the field data */
-   m_process_t proc = ((smx_process_t)arg)->data;
-   xbt_fifo_remove(msg_global->process_list, proc);
-   SIMIX_process_cleanup(arg);
-   free(proc->name);
-   proc->name = NULL;
-   free(proc->simdata);
-   proc->simdata = NULL;
-   free(proc);
-
-   return;
+  /* arg is a pointer to a simix process, we can get the msg process with the field data */
+  m_process_t proc = ((smx_process_t) arg)->data;
+  xbt_fifo_remove(msg_global->process_list, proc);
+  SIMIX_process_cleanup(arg);
+  free(proc->name);
+  proc->name = NULL;
+  free(proc->simdata);
+  proc->simdata = NULL;
+  free(proc);
+
+  return;
 }
 
 /* This function creates a MSG process. It has the prototype by SIMIX_function_register_process_create */
 void *_MSG_process_create_from_SIMIX(const char *name,
                                     xbt_main_func_t code, void *data,
 }
 
 /* This function creates a MSG process. It has the prototype by SIMIX_function_register_process_create */
 void *_MSG_process_create_from_SIMIX(const char *name,
                                     xbt_main_func_t code, void *data,
-                                    char * hostname, int argc, char **argv)
+                                    char *hostname, int argc, char **argv)
 {
 {
-       m_host_t host = MSG_get_host_by_name(hostname);
-       return (void*)MSG_process_create_with_arguments(name,code,data,host,argc,argv);
+  m_host_t host = MSG_get_host_by_name(hostname);
+  return (void *) MSG_process_create_with_arguments(name, code, data, host,
+                                                   argc, argv);
 }
 
 
 }
 
 
@@ -93,28 +96,30 @@ void *_MSG_process_create_from_SIMIX(const char *name,
  */
 
 m_process_t MSG_process_create_with_arguments(const char *name,
  */
 
 m_process_t MSG_process_create_with_arguments(const char *name,
-                                             xbt_main_func_t code, void *data,
-                                             m_host_t host, int argc, char **argv)
+                                             xbt_main_func_t code,
+                                             void *data, m_host_t host,
+                                             int argc, char **argv)
 {
 {
-  simdata_process_t simdata = xbt_new0(s_simdata_process_t,1);
-  m_process_t process = xbt_new0(s_m_process_t,1);
+  simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
+  m_process_t process = xbt_new0(s_m_process_t, 1);
   xbt_assert0(((code != NULL) && (host != NULL)), "Invalid parameters");
 
   /* Simulator Data */
   simdata->PID = msg_global->PID++;
   xbt_assert0(((code != NULL) && (host != NULL)), "Invalid parameters");
 
   /* Simulator Data */
   simdata->PID = msg_global->PID++;
-       simdata->waiting_task = NULL;
+  simdata->waiting_task = NULL;
   simdata->m_host = host;
   simdata->argc = argc;
   simdata->argv = argv;
   simdata->m_host = host;
   simdata->argc = argc;
   simdata->argv = argv;
-  simdata->s_process = SIMIX_process_create(name, code, 
-                                           (void*)process, host->name, argc, argv);
+  simdata->s_process = SIMIX_process_create(name, code,
+                                           (void *) process, host->name,
+                                           argc, argv);
 
   if (SIMIX_process_self()) {
     simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
   } else {
     simdata->PPID = -1;
   }
 
   if (SIMIX_process_self()) {
     simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
   } else {
     simdata->PPID = -1;
   }
-  simdata->last_errno=MSG_OK;
+  simdata->last_errno = MSG_OK;
 
 
   /* Process structure */
 
 
   /* Process structure */
@@ -122,14 +127,15 @@ m_process_t MSG_process_create_with_arguments(const char *name,
   process->simdata = simdata;
   process->data = data;
 
   process->simdata = simdata;
   process->data = data;
 
-  xbt_fifo_unshift(msg_global->process_list, process); 
+  xbt_fifo_unshift(msg_global->process_list, process);
 
   return process;
 }
 
 
 
   return process;
 }
 
 
-void _MSG_process_kill_from_SIMIX(void *p) {
-   MSG_process_kill((m_process_t)p);
+void _MSG_process_kill_from_SIMIX(void *p)
+{
+  MSG_process_kill((m_process_t) p);
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -144,16 +150,16 @@ void MSG_process_kill(m_process_t process)
   DEBUG3("Killing %s(%d) on %s",
         process->name, p_simdata->PID, p_simdata->m_host->name);
 
   DEBUG3("Killing %s(%d) on %s",
         process->name, p_simdata->PID, p_simdata->m_host->name);
 
-  if(p_simdata->waiting_task) {
-    DEBUG1("Canceling waiting task %s",p_simdata->waiting_task->name);
-    if(p_simdata->waiting_task->simdata->compute) {
+  if (p_simdata->waiting_task) {
+    DEBUG1("Canceling waiting task %s", p_simdata->waiting_task->name);
+    if (p_simdata->waiting_task->simdata->compute) {
       SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute);
     } else if (p_simdata->waiting_task->simdata->comm) {
       SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm);
       SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute);
     } else if (p_simdata->waiting_task->simdata->comm) {
       SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm);
-    } 
+    }
   }
 
   }
 
-  xbt_fifo_remove(msg_global->process_list,process);
+  xbt_fifo_remove(msg_global->process_list, process);
   SIMIX_process_kill(process->simdata->s_process);
 
   return;
   SIMIX_process_kill(process->simdata->s_process);
 
   return;
@@ -167,7 +173,8 @@ void MSG_process_kill(m_process_t process)
  */
 MSG_error_t MSG_process_change_host(m_process_t process, m_host_t host)
 {
  */
 MSG_error_t MSG_process_change_host(m_process_t process, m_host_t host)
 {
-       xbt_die("MSG_process_change_host - not implemented yet - maybe useless function");
+  xbt_die
+      ("MSG_process_change_host - not implemented yet - maybe useless function");
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -190,13 +197,13 @@ void *MSG_process_get_data(m_process_t process)
  * This functions checks whether \a process is a valid pointer or not 
    and set the user data associated to \a process if it is possible.
  */
  * This functions checks whether \a process is a valid pointer or not 
    and set the user data associated to \a process if it is possible.
  */
-MSG_error_t MSG_process_set_data(m_process_t process,void *data)
+MSG_error_t MSG_process_set_data(m_process_t process, void *data)
 {
   xbt_assert0((process != NULL), "Invalid parameters");
   xbt_assert0((process->data == NULL), "Data already set");
 {
   xbt_assert0((process != NULL), "Invalid parameters");
   xbt_assert0((process->data == NULL), "Data already set");
-  
+
   process->data = data;
   process->data = data;
-   
+
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
@@ -209,7 +216,8 @@ MSG_error_t MSG_process_set_data(m_process_t process,void *data)
  */
 m_host_t MSG_process_get_host(m_process_t process)
 {
  */
 m_host_t MSG_process_get_host(m_process_t process)
 {
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
 
   return (((simdata_process_t) process->simdata)->m_host);
 }
 
   return (((simdata_process_t) process->simdata)->m_host);
 }
@@ -227,8 +235,9 @@ m_process_t MSG_process_from_PID(int PID)
   xbt_fifo_item_t i = NULL;
   m_process_t process = NULL;
 
   xbt_fifo_item_t i = NULL;
   m_process_t process = NULL;
 
-  xbt_fifo_foreach(msg_global->process_list,i,process,m_process_t) {
-    if(MSG_process_get_PID(process) == PID) return process;
+  xbt_fifo_foreach(msg_global->process_list, i, process, m_process_t) {
+    if (MSG_process_get_PID(process) == PID)
+      return process;
   }
   return NULL;
 }
   }
   return NULL;
 }
@@ -244,7 +253,7 @@ int MSG_process_get_PID(m_process_t process)
   /* Do not raise an exception here: this function is used in the logs, 
      and it will be called back by the exception handling stuff */
   if (process == NULL || process->simdata == NULL)
   /* Do not raise an exception here: this function is used in the logs, 
      and it will be called back by the exception handling stuff */
   if (process == NULL || process->simdata == NULL)
-     return 0;
+    return 0;
 
   return (((simdata_process_t) process->simdata)->PID);
 }
 
   return (((simdata_process_t) process->simdata)->PID);
 }
@@ -258,7 +267,8 @@ int MSG_process_get_PID(m_process_t process)
  */
 int MSG_process_get_PPID(m_process_t process)
 {
  */
 int MSG_process_get_PPID(m_process_t process)
 {
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
 
   return (((simdata_process_t) process->simdata)->PPID);
 }
 
   return (((simdata_process_t) process->simdata)->PPID);
 }
@@ -271,7 +281,8 @@ int MSG_process_get_PPID(m_process_t process)
  */
 const char *MSG_process_get_name(m_process_t process)
 {
  */
 const char *MSG_process_get_name(m_process_t process)
 {
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
 
   return (process->name);
 }
 
   return (process->name);
 }
@@ -304,13 +315,12 @@ int MSG_process_self_PPID(void)
  */
 m_process_t MSG_process_self(void)
 {
  */
 m_process_t MSG_process_self(void)
 {
-       smx_process_t proc = SIMIX_process_self();
-       if (proc != NULL) {
-               return (m_process_t)proc->data;
-       }
-       else { 
-               return NULL;
-       }
+  smx_process_t proc = SIMIX_process_self();
+  if (proc != NULL) {
+    return (m_process_t) proc->data;
+  } else {
+    return NULL;
+  }
 
 }
 
 
 }
 
@@ -322,10 +332,11 @@ m_process_t MSG_process_self(void)
  */
 MSG_error_t MSG_process_suspend(m_process_t process)
 {
  */
 MSG_error_t MSG_process_suspend(m_process_t process)
 {
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
 
   CHECK_HOST();
 
-       SIMIX_process_suspend(process->simdata->s_process);
+  SIMIX_process_suspend(process->simdata->s_process);
   MSG_RETURN(MSG_OK);
 }
 
   MSG_RETURN(MSG_OK);
 }
 
@@ -338,10 +349,11 @@ MSG_error_t MSG_process_suspend(m_process_t process)
 MSG_error_t MSG_process_resume(m_process_t process)
 {
 
 MSG_error_t MSG_process_resume(m_process_t process)
 {
 
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
   CHECK_HOST();
 
   CHECK_HOST();
 
-       SIMIX_process_resume(process->simdata->s_process);
+  SIMIX_process_resume(process->simdata->s_process);
   MSG_RETURN(MSG_OK);
 }
 
   MSG_RETURN(MSG_OK);
 }
 
@@ -353,7 +365,7 @@ MSG_error_t MSG_process_resume(m_process_t process)
  */
 int MSG_process_is_suspended(m_process_t process)
 {
  */
 int MSG_process_is_suspended(m_process_t process)
 {
-  xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
-       return SIMIX_process_is_suspended(process->simdata->s_process);
+  xbt_assert0(((process != NULL)
+              && (process->simdata)), "Invalid parameters");
+  return SIMIX_process_is_suspended(process->simdata->s_process);
 }
 }
-
index 13c9d0d..5bb0763 100644 (file)
@@ -1,12 +1,12 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* 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. */
-  
+
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "msg/private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
  * Example:
  * MSG_config("workstation_model","KCCFLN05");
  */
  * Example:
  * MSG_config("workstation_model","KCCFLN05");
  */
-void MSG_config(const char *name, ...) {
-  
+void MSG_config(const char *name, ...)
+{
+
   if (!msg_global) {
   if (!msg_global) {
-     fprintf(stderr, "ERROR: Please call MSG_init() before using MSG_config()\n");
-     abort();
+    fprintf(stderr,
+           "ERROR: Please call MSG_init() before using MSG_config()\n");
+    abort();
   }
   }
-   
-   
+
+
   va_list pa;
   va_list pa;
-  /*  xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set);*/
-  va_start(pa,name);
-  
-  SIMIX_config(name,pa);
-  
+  /*  xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set); */
+  va_start(pa, name);
+
+  SIMIX_config(name, pa);
+
   va_end(pa);
   return;
 }
   va_end(pa);
   return;
 }
index ebe69c3..62bcdac 100644 (file)
@@ -1,5 +1,5 @@
 /*     $Id$      */
 /*     $Id$      */
-  
+
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* All rights reserved.                                                     */
 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
 /* Copyright (c) 2007 Bruno Donassolo.                                      */
 /* All rights reserved.                                                     */
@@ -49,8 +49,8 @@
 m_task_t MSG_task_create(const char *name, double compute_duration,
                         double message_size, void *data)
 {
 m_task_t MSG_task_create(const char *name, double compute_duration,
                         double message_size, void *data)
 {
-       m_task_t task = xbt_new(s_m_task_t,1);
-  simdata_task_t simdata = xbt_new(s_simdata_task_t,1);
+  m_task_t task = xbt_new(s_m_task_t, 1);
+  simdata_task_t simdata = xbt_new(s_simdata_task_t, 1);
   task->simdata = simdata;
   /* Task structure */
   task->name = xbt_strdup(name);
   task->simdata = simdata;
   /* Task structure */
   task->name = xbt_strdup(name);
@@ -64,14 +64,14 @@ m_task_t MSG_task_create(const char *name, double compute_duration,
   simdata->using = 1;
   simdata->sender = NULL;
   simdata->receiver = NULL;
   simdata->using = 1;
   simdata->sender = NULL;
   simdata->receiver = NULL;
-       simdata->cond = SIMIX_cond_init();
-       simdata->mutex = SIMIX_mutex_init();
-       simdata->compute = NULL;
-       simdata->comm = NULL;
+  simdata->cond = SIMIX_cond_init();
+  simdata->mutex = SIMIX_mutex_init();
+  simdata->compute = NULL;
+  simdata->comm = NULL;
 
 
-       simdata->host_list = NULL;
-       simdata->comp_amount = NULL;
-       simdata->comm_amount = NULL;
+  simdata->host_list = NULL;
+  simdata->comp_amount = NULL;
+  simdata->comm_amount = NULL;
 
   return task;
 }
 
   return task;
 }
@@ -96,8 +96,8 @@ void *MSG_task_get_data(m_task_t task)
  */
 m_process_t MSG_task_get_sender(m_task_t task)
 {
  */
 m_process_t MSG_task_get_sender(m_task_t task)
 {
-   xbt_assert0(task, "Invalid parameters");
-   return ((simdata_task_t) task->simdata)->sender;
+  xbt_assert0(task, "Invalid parameters");
+  return ((simdata_task_t) task->simdata)->sender;
 }
 
 /** \ingroup m_task_management
 }
 
 /** \ingroup m_task_management
@@ -107,8 +107,8 @@ m_process_t MSG_task_get_sender(m_task_t task)
  */
 m_host_t MSG_task_get_source(m_task_t task)
 {
  */
 m_host_t MSG_task_get_source(m_task_t task)
 {
-   xbt_assert0(task, "Invalid parameters");
-   return ((simdata_task_t) task->simdata)->source;
+  xbt_assert0(task, "Invalid parameters");
+  return ((simdata_task_t) task->simdata)->source;
 }
 
 /** \ingroup m_task_management
 }
 
 /** \ingroup m_task_management
@@ -118,8 +118,8 @@ m_host_t MSG_task_get_source(m_task_t task)
  */
 const char *MSG_task_get_name(m_task_t task)
 {
  */
 const char *MSG_task_get_name(m_task_t task)
 {
-   xbt_assert0(task, "Invalid parameters");
-   return task->name;
+  xbt_assert0(task, "Invalid parameters");
+  return task->name;
 }
 
 
 }
 
 
@@ -134,25 +134,30 @@ MSG_error_t MSG_task_destroy(m_task_t task)
   smx_action_t action = NULL;
   xbt_assert0((task != NULL), "Invalid parameter");
 
   smx_action_t action = NULL;
   xbt_assert0((task != NULL), "Invalid parameter");
 
-       /* why? if somebody is using, then you can't free! ok... but will return MSG_OK? when this task will be destroyed? isn't the user code wrong? */
+  /* why? if somebody is using, then you can't free! ok... but will return MSG_OK? when this task will be destroyed? isn't the user code wrong? */
   task->simdata->using--;
   task->simdata->using--;
-  if(task->simdata->using>0) return MSG_OK;
+  if (task->simdata->using > 0)
+    return MSG_OK;
 
 
-  if(task->name) free(task->name);
+  if (task->name)
+    free(task->name);
 
 
-       SIMIX_cond_destroy(task->simdata->cond);
-       SIMIX_mutex_destroy(task->simdata->mutex);
+  SIMIX_cond_destroy(task->simdata->cond);
+  SIMIX_mutex_destroy(task->simdata->mutex);
 
   action = task->simdata->compute;
 
   action = task->simdata->compute;
-  if(action) SIMIX_action_destroy(action);
+  if (action)
+    SIMIX_action_destroy(action);
   action = task->simdata->comm;
   action = task->simdata->comm;
-  if(action) SIMIX_action_destroy(action);
-       /* parallel tasks only */ 
-  if(task->simdata->host_list) xbt_free(task->simdata->host_list);
-       
-       /* free main structures */
-       xbt_free(task->simdata);
-       xbt_free(task);
+  if (action)
+    SIMIX_action_destroy(action);
+  /* parallel tasks only */
+  if (task->simdata->host_list)
+    xbt_free(task->simdata->host_list);
+
+  /* free main structures */
+  xbt_free(task->simdata);
+  xbt_free(task);
 
   return MSG_OK;
 }
 
   return MSG_OK;
 }
@@ -167,12 +172,12 @@ MSG_error_t MSG_task_cancel(m_task_t task)
 {
   xbt_assert0((task != NULL), "Invalid parameter");
 
 {
   xbt_assert0((task != NULL), "Invalid parameter");
 
-  if(task->simdata->compute) {
-               SIMIX_action_cancel(task->simdata->compute);
+  if (task->simdata->compute) {
+    SIMIX_action_cancel(task->simdata->compute);
     return MSG_OK;
   }
     return MSG_OK;
   }
-  if(task->simdata->comm) {
-               SIMIX_action_cancel(task->simdata->comm);
+  if (task->simdata->comm) {
+    SIMIX_action_cancel(task->simdata->comm);
     return MSG_OK;
   }
 
     return MSG_OK;
   }
 
@@ -183,9 +188,10 @@ MSG_error_t MSG_task_cancel(m_task_t task)
  * \brief Returns the computation amount needed to process a task #m_task_t.
  *        Once a task has been processed, this amount is thus set to 0...
  */
  * \brief Returns the computation amount needed to process a task #m_task_t.
  *        Once a task has been processed, this amount is thus set to 0...
  */
-double MSG_task_get_compute_duration(m_task_t task) 
+double MSG_task_get_compute_duration(m_task_t task)
 {
 {
-  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+  xbt_assert0((task != NULL)
+             && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->computation_amount;
 }
 
   return task->simdata->computation_amount;
 }
@@ -196,9 +202,10 @@ double MSG_task_get_compute_duration(m_task_t task)
  */
 double MSG_task_get_remaining_computation(m_task_t task)
 {
  */
 double MSG_task_get_remaining_computation(m_task_t task)
 {
-  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+  xbt_assert0((task != NULL)
+             && (task->simdata != NULL), "Invalid parameter");
 
 
-  if(task->simdata->compute) {
+  if (task->simdata->compute) {
     return SIMIX_action_get_remains(task->simdata->compute);
   } else {
     return task->simdata->computation_amount;
     return SIMIX_action_get_remains(task->simdata->compute);
   } else {
     return task->simdata->computation_amount;
@@ -209,9 +216,10 @@ double MSG_task_get_remaining_computation(m_task_t task)
  * \brief Returns the size of the data attached to a task #m_task_t.
  *
  */
  * \brief Returns the size of the data attached to a task #m_task_t.
  *
  */
-double MSG_task_get_data_size(m_task_t task) 
+double MSG_task_get_data_size(m_task_t task)
 {
 {
-  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+  xbt_assert0((task != NULL)
+             && (task->simdata != NULL), "Invalid parameter");
 
   return task->simdata->message_size;
 }
 
   return task->simdata->message_size;
 }
@@ -224,12 +232,13 @@ double MSG_task_get_data_size(m_task_t task)
  *        cpu power than the other ones.
  *
  */
  *        cpu power than the other ones.
  *
  */
-void MSG_task_set_priority(m_task_t task, double priority) 
+void MSG_task_set_priority(m_task_t task, double priority)
 {
 {
-  xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter");
+  xbt_assert0((task != NULL)
+             && (task->simdata != NULL), "Invalid parameter");
 
 
-  task->simdata->priority = 1/priority;
-  if(task->simdata->compute)
-               SIMIX_action_set_priority(task->simdata->compute, task->simdata->priority);
+  task->simdata->priority = 1 / priority;
+  if (task->simdata->compute)
+    SIMIX_action_set_priority(task->simdata->compute,
+                             task->simdata->priority);
 }
 }
-