Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean indentation and coding style in SIMIX
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 17:18:52 +0000 (17:18 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 17:18:52 +0000 (17:18 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8910 48e7efb5-ca39-0410-a469-dd3cf9ba447f

22 files changed:
src/simix/network_private.h
src/simix/private.h
src/simix/process_private.h
src/simix/smurf_private.h
src/simix/smx_context.c
src/simix/smx_context_base.c
src/simix/smx_context_java.c
src/simix/smx_context_java.h
src/simix/smx_context_private.h
src/simix/smx_context_ruby.c
src/simix/smx_context_sysv.c
src/simix/smx_context_sysv_private.h
src/simix/smx_context_thread.c
src/simix/smx_deployment.c
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_network.c
src/simix/smx_process.c
src/simix/smx_smurf.c
src/simix/smx_synchro.c
src/simix/smx_user.c
src/simix/synchro_private.h

index e49a47a..845eba2 100644 (file)
@@ -52,5 +52,6 @@ size_t SIMIX_comm_get_src_buff_size(smx_action_t action);
 size_t SIMIX_comm_get_dst_buff_size(smx_action_t action);
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action);
 smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action);
+
 #endif
 
index 53f20eb..34cac50 100644 (file)
@@ -122,7 +122,7 @@ typedef struct s_smx_action {
     struct {
       surf_action_t sleep;
     } synchro;
-    
+
   };
 
 #ifdef HAVE_TRACING
@@ -155,9 +155,8 @@ static XBT_INLINE e_smx_state_t SIMIX_action_map_state(e_surf_action_state_t sta
 
 
 typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
- (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
-typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t
-                                                   *);
+  (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
+typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
 typedef void (*smx_pfn_context_free_t) (smx_context_t);
 typedef void (*smx_pfn_context_start_t) (smx_context_t);
 typedef void (*smx_pfn_context_stop_t) (smx_context_t);
@@ -181,13 +180,12 @@ typedef struct s_smx_context_factory {
 
 
 void SIMIX_context_mod_init(void);
-
 void SIMIX_context_mod_exit(void);
 
 
 /* All factories init */
-void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory);
-void SIMIX_ctx_sysv_factory_init(smx_context_factory_t * factory);
+void SIMIX_ctx_thread_factory_init(smx_context_factory_t *factory);
+void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory);
 
 /* ****************************** */
 /* context manipulation functions */
@@ -278,6 +276,7 @@ static XBT_INLINE smx_context_t SIMIX_context_self(void)
   return (*(simix_global->context_factory->self))();
 }
 
+<<<<<<< HEAD
 /**
  \brief returns the data associated to a context
  \param context The context
@@ -289,4 +288,6 @@ static XBT_INLINE void* SIMIX_context_get_data(smx_context_t context)
 }
 
 
+=======
+>>>>>>> Clean indentation and coding style in SIMIX
 #endif
index 3641d74..35d5797 100644 (file)
@@ -18,7 +18,7 @@ typedef struct s_smx_process {
   s_xbt_swag_hookup_t synchro_hookup;   /* process_to_run or mutex->sleeping and co */
   s_xbt_swag_hookup_t host_proc_hookup;
   s_xbt_swag_hookup_t destroy_hookup;
-  
+
   unsigned long pid;
   char *name;                   /**< @brief process name if any */
   smx_host_t smx_host;          /* the host on which the process is running */
index 3a31142..1725cf6 100644 (file)
@@ -255,7 +255,7 @@ typedef struct s_smx_req {
       const char* name;
       smx_rdv_t result;
     } rdv_get_by_name;
-    
+
     struct {
       smx_rdv_t rdv;
       smx_host_t host;
@@ -266,7 +266,7 @@ typedef struct s_smx_req {
       smx_rdv_t rdv;
       smx_action_t result;
     } rdv_get_head;
+
     struct {
       smx_rdv_t rdv;
       double task_size;
@@ -291,12 +291,12 @@ typedef struct s_smx_req {
     struct {
       smx_action_t comm;
     } comm_cancel;
+
     struct {
       xbt_dynar_t comms;
       unsigned int result;
     } comm_waitany;
+
     struct {
       smx_action_t comm;
       double timeout;
@@ -311,42 +311,42 @@ typedef struct s_smx_req {
       smx_action_t comm;
       double result;
     } comm_get_remains;
+
     struct {
       smx_action_t comm;
       e_smx_state_t result;
     } comm_get_state;
+
     struct {
       smx_action_t comm;
       void *result;    
     } comm_get_data;
+
     struct {
       smx_action_t comm;
       void *result;
     } comm_get_src_buff;
+
     struct {
       smx_action_t comm;
       void *result;
     } comm_get_dst_buff;
-    
+
     struct {
       smx_action_t comm;
       size_t result;
     } comm_get_src_buff_size;
-    
+
     struct {
       smx_action_t comm;
       size_t result;
     } comm_get_dst_buff_size;
-    
+
     struct {
       smx_action_t comm;
       smx_process_t result;
     } comm_get_src_proc;
-    
+
     struct {
       smx_action_t comm;
       smx_process_t result;
@@ -452,5 +452,6 @@ void SIMIX_request_pre(smx_req_t);
 void SIMIX_request_post(smx_action_t);
 int SIMIX_request_isVisible(smx_req_t req);
 int SIMIX_request_isEnabled(smx_req_t req);
+
 #endif
 
index 281c2d8..e15fbfc 100644 (file)
@@ -26,7 +26,8 @@ void SIMIX_context_mod_init(void)
     /* select context factory to use to create the context(depends of the macro definitions) */
     if (factory_initializer_to_use) {
       (*factory_initializer_to_use)(&(simix_global->context_factory));
-    } else {
+    }
+    else {
 #ifdef CONTEXT_THREADS /* Use os threads (either pthreads or windows ones) */
       SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
 #elif defined(CONTEXT_UCONTEXT) /* use ucontext */
index bf79ab2..883e83b 100644 (file)
@@ -12,7 +12,7 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(bindings);
 
-void smx_ctx_base_factory_init(smx_context_factory_t * factory)
+void smx_ctx_base_factory_init(smx_context_factory_t *factory)
 {
   /* instantiate the context factory */
   *factory = xbt_new0(s_smx_context_factory_t, 1);
@@ -95,4 +95,4 @@ smx_context_t smx_ctx_base_self(void)
 void *smx_ctx_base_get_data(smx_context_t context)
 {
   return context->data;
-}
\ No newline at end of file
+}
index 2c4d045..9b69a5c 100644 (file)
@@ -105,7 +105,6 @@ static void smx_ctx_java_stop(smx_context_t context)
 
         /* interrupt the java process */
         jprocess_exit(jprocess, get_current_thread_env());
-
       }
     }
   } else {
@@ -150,7 +149,7 @@ static void smx_ctx_java_runall(xbt_swag_t processes)
   smx_process_t process;
   smx_context_t old_context;
   
-  while((process = xbt_swag_extract(processes))){
+  while ((process = xbt_swag_extract(processes))) {
     old_context = smx_current_context;
     smx_current_context = process->context;
     smx_ctx_java_resume(smx_current_context);
index a60ae04..31fb3b6 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "portable.h"
 #include "xbt/misc.h"
-
 #include "smx_context_private.h"
 #include "java/jmsg.h"
 #include "java/jmsg_process.h"
@@ -18,10 +17,12 @@ SG_BEGIN_DECL()
 
 typedef struct s_smx_ctx_java {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
-  jobject jprocess;             /* the java process instance binded with the msg process structure                                                      */
-  JNIEnv *jenv;                 /* jni interface pointer associated to this thread                                                                                      */
+  jobject jprocess;             /* the java process instance binded with the msg process structure */
+  JNIEnv *jenv;                 /* jni interface pointer associated to this thread */
 } s_smx_ctx_java_t, *smx_ctx_java_t;
-void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory);
+
+void SIMIX_ctx_java_factory_init(smx_context_factory_t *factory);
 
 SG_END_DECL()
+
 #endif                          /* !_XBT_CONTEXT_JAVA_H */
index 9e56c1a..bf2d95f 100644 (file)
@@ -14,7 +14,7 @@
 
 SG_BEGIN_DECL()
 /*Hack: let msg load directly the right factory */
-typedef void (*SIMIX_ctx_factory_initializer_t)(smx_context_factory_t *);
+typedef void (*SIMIX_ctx_factory_initializer_t)(smx_context_factory_t*);
 extern SIMIX_ctx_factory_initializer_t factory_initializer_to_use;
 
 extern int _surf_parallel_contexts;
@@ -35,9 +35,10 @@ typedef struct s_smx_context {
   void_pfn_smxprocess_t cleanup_func;
   void *data;   /* Here SIMIX stores the smx_process_t containing the context */
 } s_smx_ctx_base_t;
+
 /* methods of this class */
-void smx_ctx_base_factory_init(smx_context_factory_t * factory);
-int smx_ctx_base_factory_finalize(smx_context_factory_t * factory);
+void smx_ctx_base_factory_init(smx_context_factory_t *factory);
+int smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
 
 smx_context_t
 smx_ctx_base_factory_create_context_sized(size_t size,
@@ -51,4 +52,5 @@ smx_context_t smx_ctx_base_self(void);
 void *smx_ctx_base_get_data(smx_context_t context);
 
 SG_END_DECL()
+
 #endif                          /* !_XBT_CONTEXT_PRIVATE_H */
index 215e157..ad7f1e0 100644 (file)
@@ -43,8 +43,7 @@ void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory)
 
 static smx_context_t
 smx_ctx_ruby_create_context(xbt_main_func_t code, int argc, char **argv,
-    void_pfn_smxprocess_t cleanup_func,
-    smx_process_t process)
+    void_pfn_smxprocess_t cleanup_func, smx_process_t process)
 {
 
   smx_ctx_ruby_t context = (smx_ctx_ruby_t)
@@ -109,15 +108,14 @@ static void smx_ctx_ruby_resume(smx_context_t new_context)
 
   smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context;
   rb_process_schedule(ctx_ruby->process);
-
 }
 
 static void smx_ctx_ruby_runall(xbt_swag_t processes)
 {
   smx_process_t process;
-  while((process = xbt_swag_extract(processes))){
+  while ((process = xbt_swag_extract(processes))) {
     simix_global->current_process = process;
     smx_ctx_ruby_resume(process->context);
     simix_global->current_process = simix_global->maestro_process;
   } 
-}
\ No newline at end of file
+}
index 9458a3b..c0c1a02 100644 (file)
@@ -6,8 +6,6 @@
  /* 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 "smx_context_sysv_private.h"
 #include "xbt/threadpool.h"
 
@@ -33,7 +31,7 @@ smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
 
 static void smx_ctx_sysv_wrapper(smx_ctx_sysv_t context);
 
-void SIMIX_ctx_sysv_factory_init(smx_context_factory_t * factory)
+void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory)
 {
   smx_ctx_base_factory_init(factory);
 
@@ -172,7 +170,7 @@ void smx_ctx_sysv_runall(xbt_swag_t processes)
   smx_context_t old_context;
   smx_process_t process;
   
-  while((process = xbt_swag_extract(processes))){
+  while ((process = xbt_swag_extract(processes))) {
     old_context = smx_current_context;
     smx_current_context = process->context;
     smx_ctx_sysv_resume(smx_current_context);
@@ -186,4 +184,4 @@ void smx_ctx_sysv_runall_parallel(xbt_swag_t processes)
   while((process = xbt_swag_extract(processes))){
     xbt_tpool_queue_job(tpool, (void_f_pvoid_t)smx_ctx_sysv_resume, process->context);
   }
-}
\ No newline at end of file
+}
index 193f9c9..56f3fb5 100644 (file)
@@ -15,8 +15,6 @@
 
 SG_BEGIN_DECL()
 
-
-
 /* lower this if you want to reduce the memory consumption  */
 #ifndef CONTEXT_STACK_SIZE      /* allow lua to override this */
 #define CONTEXT_STACK_SIZE 128*1024
@@ -27,6 +25,7 @@ SG_BEGIN_DECL()
 #else
 #include <ucontext.h>           /* context relative declarations */
 #endif
+
 typedef struct s_smx_ctx_sysv {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
   ucontext_t uc;                /* the thread that execute the code */
@@ -36,7 +35,6 @@ typedef struct s_smx_ctx_sysv {
   char stack[CONTEXT_STACK_SIZE];       /* the thread stack size */
 } s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
 
-
 void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory);
 int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory);
 
@@ -54,4 +52,5 @@ void smx_ctx_sysv_runall(xbt_swag_t processes);
 void smx_ctx_sysv_runall_parallel(xbt_swag_t processes);
 
 SG_END_DECL()
+
 #endif                          /* !_XBT_CONTEXT_SYSV_PRIVATE_H */
index fe51290..541aa8c 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "xbt/function_types.h"
 #include "private.h"
-
 #include "portable.h"           /* loads context system definitions */
 #include "xbt/swag.h"
 #include "xbt/xbt_os_thread.h"
@@ -42,7 +41,6 @@ static void *smx_ctx_thread_wrapper(void *param);
 
 void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory)
 {
-
   smx_ctx_base_factory_init(factory);
 
   (*factory)->create_context = smx_ctx_thread_factory_create_context;
@@ -55,7 +53,7 @@ void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory)
     (*factory)->runall = smx_ctx_thread_runall_parallel;
   else
     (*factory)->runall = smx_ctx_thread_runall_serial;
-  
+
   (*factory)->self = smx_ctx_thread_self;
   (*factory)->name = "ctx_thread_factory";
 }
@@ -79,7 +77,7 @@ smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
 
     /* delay the thread creation until first run */
     context->thread = NULL;
+
   } else {
     xbt_os_thread_set_extra_data(process);
   }
@@ -97,20 +95,19 @@ static void smx_ctx_thread_free(smx_context_t pcontext)
     /* wait about the thread terminason */
     xbt_os_thread_join(context->thread, NULL);
   }
-  
+
   /* destroy the synchronisation objects */
-  if(context->begin)
+  if (context->begin)
     xbt_os_sem_destroy(context->begin);
 
-  if(context->end)
+  if (context->end)
     xbt_os_sem_destroy(context->end);
-  
+
   smx_ctx_base_free(pcontext);
 }
 
 static void smx_ctx_thread_stop(smx_context_t pcontext)
 {
-
   smx_ctx_thread_t context = (smx_ctx_thread_t) pcontext;
 
   /* please no debug here: our procdata was already free'd */
@@ -140,7 +137,7 @@ static void *smx_ctx_thread_wrapper(void *param)
 
 static void smx_ctx_thread_suspend(smx_context_t context)
 {
-  if(((smx_ctx_thread_t) context)->thread){
+  if (((smx_ctx_thread_t) context)->thread) {
     xbt_os_sem_release(((smx_ctx_thread_t) context)->end);
     xbt_os_sem_acquire(((smx_ctx_thread_t) context)->begin);
   }
@@ -149,36 +146,37 @@ static void smx_ctx_thread_suspend(smx_context_t context)
 static void smx_ctx_thread_runall_serial(xbt_swag_t processes)
 {
   smx_process_t process;
-  while((process = xbt_swag_extract(processes))){
+  while ((process = xbt_swag_extract(processes))) {
     /* if the context has no thread associated, create one for it (first run) */
-    if(!(((smx_ctx_thread_t)process->context)->thread)){
-      ((smx_ctx_thread_t)process->context)->thread =
+    if (!(((smx_ctx_thread_t)process->context)->thread)) {
+      ((smx_ctx_thread_t) process->context)->thread =
         xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, process->context, process);
-      xbt_os_sem_acquire(((smx_ctx_thread_t)process->context)->end);
+      xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
     }
-    xbt_os_sem_release(((smx_ctx_thread_t) (process->context))->begin);
-    xbt_os_sem_acquire(((smx_ctx_thread_t) (process->context))->end);
+    xbt_os_sem_release(((smx_ctx_thread_t) process->context)->begin);
+    xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
   }  
 }
 
-static void smx_ctx_thread_runall_parallel(xbt_swag_t processes){
+static void smx_ctx_thread_runall_parallel(xbt_swag_t processes)
+{
   smx_process_t process, p_next;
-  xbt_swag_foreach_safe(process, p_next, processes){
+  xbt_swag_foreach_safe(process, p_next, processes) {
     /* if the context has no thread associated, create one for it (first run) */
-    if(!(((smx_ctx_thread_t)process->context)->thread)){
+    if (!(((smx_ctx_thread_t) process->context)->thread)) {
       ((smx_ctx_thread_t)process->context)->thread =
         xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, process->context, process);
-      xbt_os_sem_acquire(((smx_ctx_thread_t)process->context)->end);
+      xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
     }
-    xbt_os_sem_release(((smx_ctx_thread_t) (process->context))->begin);
+    xbt_os_sem_release(((smx_ctx_thread_t) process->context)->begin);
   }
 
-  while((process = xbt_swag_extract(processes))){
-    xbt_os_sem_acquire(((smx_ctx_thread_t) (process->context))->end);
+  while ((process = xbt_swag_extract(processes))) {
+    xbt_os_sem_acquire(((smx_ctx_thread_t) process->context)->end);
   }
 }
 
 static smx_process_t smx_ctx_thread_self(void)
 {
   return (smx_process_t) xbt_os_thread_get_extra_data();
-}
\ No newline at end of file
+}
index 539a0ed..7a4a180 100644 (file)
@@ -4,7 +4,6 @@
 /* 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 "private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -212,7 +211,6 @@ void SIMIX_process_set_function(const char *process_host,
     parse_argv[(parse_argc) - 1] = xbt_strdup(arg);
   }
 
-  /*finalize */
+  /* finalize */
   parse_process_finalize();
-
 }
index d736082..d6b84ed 100644 (file)
@@ -96,7 +96,7 @@ void SIMIX_global_init(int *argc, char **argv)
 
     /* Initialize the SIMIX network module */
     SIMIX_network_init();
-    
+
     /* Prepare to display some more info when dying on Ctrl-C pressing */
     signal(SIGINT, inthandler);
     surf_init(argc, argv);      /* Initialize SURF structures */
@@ -118,10 +118,10 @@ void SIMIX_clean(void)
 
   /* Exit the SIMIX network module */
   SIMIX_network_exit();
-  
+
   /* Exit request mechanism */
   SIMIX_request_destroy();
-  
+
   xbt_heap_free(simix_timers);
   /* Free the remaining data structures */
   xbt_swag_free(simix_global->process_to_run);
@@ -177,12 +177,12 @@ void SIMIX_run(void)
   smx_timer_t timer;
   surf_model_t model;
   unsigned int iter;
+
   do {
     do {
       DEBUG0("New Schedule Round");
       SIMIX_context_runall(simix_global->process_to_run);
-      while((req = SIMIX_request_pop())){
+      while ((req = SIMIX_request_pop())) {
         DEBUG1("Handling request %p", req);
         SIMIX_request_pre(req);
       }
@@ -193,7 +193,7 @@ void SIMIX_run(void)
     /* Notify all the hosts that have failed */
     /* FIXME: iterate through the list of failed host and mark each of them */
     /* as failed. On each host, signal all the running processes with host_fail */
-    
+
     /* Handle any pending timer */
     while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) {
        //FIXME: make the timers being real callbacks
@@ -204,16 +204,16 @@ void SIMIX_run(void)
     }
     /* Wake up all process waiting for the action finish */
     xbt_dynar_foreach(model_list, iter, model) {
-      for(set = model->states.failed_action_set;
-          set;
-          set = (set == model->states.failed_action_set)
-                ? model->states.done_action_set
-                : NULL) {
+      for (set = model->states.failed_action_set;
+           set;
+           set = (set == model->states.failed_action_set)
+                 ? model->states.done_action_set
+                 : NULL) {
         while ((action = xbt_swag_extract(set)))
-          SIMIX_request_post((smx_action_t)action->data);
+          SIMIX_request_post((smx_action_t) action->data);
       }
     }
-  } while(time != -1.0);
+  } while (time != -1.0);
 
 }
 
index e8d184a..fec6e69 100644 (file)
@@ -186,14 +186,14 @@ smx_action_t SIMIX_host_execute(const char *name, smx_host_t host,
   action->request_list = xbt_fifo_new();
   action->state = SIMIX_RUNNING;
   action->execution.host = host;
-  
+
 #ifdef HAVE_TRACING
   action->category = NULL;
 #endif
 
 #ifdef HAVE_MC
   /* set surf's action */
-  if(!_surf_do_model_check)
+  if (!_surf_do_model_check)
 #endif
   {
   action->execution.surf_exec =
@@ -201,14 +201,14 @@ smx_action_t SIMIX_host_execute(const char *name, smx_host_t host,
                                                           computation_amount);
   surf_workstation_model->action_data_set(action->execution.surf_exec, action);
   }
-  
+
 #ifdef HAVE_TRACING
   TRACE_smx_host_execute(action);
   TRACE_surf_action(action->execution.surf_exec, action->category);
 #endif
 
   DEBUG1("Create execute action %p", action);
-  
+
   return action;
 }
 
@@ -227,7 +227,7 @@ smx_action_t SIMIX_host_parallel_execute( const char *name,
   action->request_list = xbt_fifo_new();
   action->state = SIMIX_RUNNING;
   action->execution.host = NULL; /* FIXME: do we need the list of hosts? */
+
 #ifdef HAVE_TRACING
   action->category = NULL;
 #endif
@@ -239,13 +239,13 @@ smx_action_t SIMIX_host_parallel_execute( const char *name,
 
 #ifdef HAVE_MC
   /* set surf's action */
-  if(!_surf_do_model_check)
+  if (!_surf_do_model_check)
 #endif  
   {
-  action->execution.surf_exec = 
-    surf_workstation_model->extension.workstation.
-    execute_parallel_task(host_nb, workstation_list, computation_amount,
-                          communication_amount, amount, rate);
+    action->execution.surf_exec =
+      surf_workstation_model->extension.workstation.
+      execute_parallel_task(host_nb, workstation_list, computation_amount,
+                           communication_amount, amount, rate);
 
   surf_workstation_model->action_data_set(action->execution.surf_exec, action);
   }
@@ -263,11 +263,11 @@ void SIMIX_host_execution_destroy(smx_action_t action)
 
   xbt_fifo_free(action->request_list);
 
-  if (action->execution.surf_exec){
+  if (action->execution.surf_exec) {
     surf_workstation_model->action_unref(action->execution.surf_exec);
     action->execution.surf_exec = NULL;
   }
-  
+
 #ifdef HAVE_TRACING
   TRACE_smx_action_destroy(action);
 #endif
@@ -278,15 +278,15 @@ void SIMIX_host_execution_cancel(smx_action_t action)
 {
   DEBUG1("Cancel action %p", action);
 
-  if(action->execution.surf_exec) 
+  if (action->execution.surf_exec) 
     surf_workstation_model->action_cancel(action->execution.surf_exec);
 }
 
 double SIMIX_host_execution_get_remains(smx_action_t action)
 {
-  double result = 0;
-  
-  if(action->state == SIMIX_RUNNING)
+  double result = 0.0;
+
+  if (action->state == SIMIX_RUNNING)
     result = surf_workstation_model->get_remains(action->execution.surf_exec);
 
   return result;
@@ -314,12 +314,12 @@ void SIMIX_pre_host_execution_wait(smx_req_t req)
 
 #ifdef HAVE_MC
   /* set surf's action */
-  if(_surf_do_model_check){
+  if (_surf_do_model_check){
     action->state = SIMIX_DONE;
     SIMIX_execution_finish(action);
   }
 #endif  
-    
+
   /* If the action is already finished then perform the error handling */
   if (action->state != SIMIX_RUNNING)
     SIMIX_execution_finish(action);
@@ -327,12 +327,12 @@ void SIMIX_pre_host_execution_wait(smx_req_t req)
 
 void SIMIX_host_execution_suspend(smx_action_t action)
 {
-    surf_workstation_model->suspend(action->execution.surf_exec);
+  surf_workstation_model->suspend(action->execution.surf_exec);
 }
 
 void SIMIX_host_execution_resume(smx_action_t action)
 {
-    surf_workstation_model->suspend(action->execution.surf_exec);
+  surf_workstation_model->suspend(action->execution.surf_exec);
 }
 
 void SIMIX_execution_finish(smx_action_t action)
@@ -348,7 +348,7 @@ void SIMIX_execution_finish(smx_action_t action)
         /* do nothing, action done*/
        DEBUG0("SIMIX_execution_finished: execution successful");
         break;
-        
+
       case SIMIX_FAILED:
         TRY {
          DEBUG1("SIMIX_execution_finished: host '%s' failed", req->issuer->smx_host->name);
@@ -358,7 +358,7 @@ void SIMIX_execution_finish(smx_action_t action)
          req->issuer->doexception = 1;
        }
       break;
-        
+
       case SIMIX_CANCELED:
         TRY {
          DEBUG0("SIMIX_execution_finished: execution canceled");
@@ -368,7 +368,7 @@ void SIMIX_execution_finish(smx_action_t action)
          req->issuer->doexception = 1;
         }
        break;
-        
+
       default:
         THROW_IMPOSSIBLE;
     }
@@ -388,11 +388,11 @@ void SIMIX_post_host_execute(smx_action_t action)
   else
      action->state = SIMIX_DONE;
 
-  if (action->execution.surf_exec){
+  if (action->execution.surf_exec) {
     surf_workstation_model->action_unref(action->execution.surf_exec);
     action->execution.surf_exec = NULL;
   }
-  
+
   /* If there are requests associated with the action, then answer them */
   if (xbt_fifo_size(action->request_list))
     SIMIX_execution_finish(action);
index 1a7e1cd..f456aeb 100644 (file)
@@ -167,7 +167,7 @@ smx_action_t SIMIX_comm_new(e_smx_comm_type_t type)
 #endif
 
   DEBUG1("Create communicate action %p", act);
-  
+
   return act;
 }
 
@@ -179,8 +179,8 @@ void SIMIX_comm_destroy(smx_action_t action)
 {
   DEBUG1("Destroy action %p", action);
 
-  if(!(action->comm.refcount > 0))
-         xbt_die(bprintf("the refcount of comm %p is already 0 before decreasing it. That's a bug!",action));
+  if (action->comm.refcount <= 0)
+    xbt_die(bprintf("the refcount of comm %p is already 0 before decreasing it. That's a bug!",action));
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   //save is latency limited flag to use afterwards
@@ -243,7 +243,7 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
   if (!action) {
     action = SIMIX_comm_new(SIMIX_COMM_SEND);
     SIMIX_rdv_push(rdv, action);
-  }else{
+  } else {
     action->state = SIMIX_READY;
     action->comm.type = SIMIX_COMM_READY;
   }
@@ -256,7 +256,7 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
   action->comm.src_buff_size = src_buff_size;
   action->comm.data = data;
 #ifdef HAVE_MC
-  if(_surf_do_model_check){
+  if (_surf_do_model_check){
     action->state = SIMIX_RUNNING;
     return action;
   }
@@ -289,7 +289,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
   action->comm.dst_buff_size = dst_buff_size;
 
 #ifdef HAVE_MC
-  if(_surf_do_model_check){
+  if (_surf_do_model_check){
     action->state = SIMIX_RUNNING;
     return action;
   }
@@ -310,7 +310,7 @@ void SIMIX_pre_comm_wait(smx_req_t req)
   req->issuer->waiting_action = action;
 
 #ifdef HAVE_MC
-  if(_surf_do_model_check){
+  if (_surf_do_model_check){
     action->state = SIMIX_DONE;
     SIMIX_comm_finish(action);
   }
@@ -353,7 +353,7 @@ void SIMIX_pre_comm_waitany(smx_req_t req)
   xbt_dynar_foreach(actions, cursor, action){
     /* Associate this request to the action */
     xbt_fifo_push(action->request_list, req);
-    if(action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING){
+    if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING){
       SIMIX_comm_finish(action);
       break;
     }
@@ -383,11 +383,10 @@ static XBT_INLINE void SIMIX_comm_start(smx_action_t action)
     smx_host_t receiver = action->comm.dst_proc->smx_host;
 
     DEBUG3("Starting communication %p from '%s' to '%s'", action,
-         SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
+           SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
 
-    action->comm.surf_comm =
-      surf_workstation_model->extension.workstation.
-      communicate(sender->host, receiver->host, action->comm.task_size, action->comm.rate);
+    action->comm.surf_comm = surf_workstation_model->extension.workstation.
+        communicate(sender->host, receiver->host, action->comm.task_size, action->comm.rate);
 
     surf_workstation_model->action_data_set(action->comm.surf_comm, action);
 
@@ -420,19 +419,19 @@ void SIMIX_comm_finish(smx_action_t action)
 {
   smx_req_t req;
 
-  while((req = xbt_fifo_shift(action->request_list))){
+  while ((req = xbt_fifo_shift(action->request_list))) {
 
     /* If a waitany request is waiting for this action to finish, then remove
        it from the other actions in the waitany list. Afterwards, get the
        position of the actual action in the waitany request's actions dynar and
        return it as the result of the call */
-    if(req->call == REQ_COMM_WAITANY){
+    if (req->call == REQ_COMM_WAITANY) {
       SIMIX_waitany_req_remove_from_actions(req);
       req->comm_waitany.result = xbt_dynar_search(req->comm_waitany.comms, &action);
     }
 
     /* If the action is still in a rendez-vous point then remove from it */
-    if(action->comm.rdv)
+    if (action->comm.rdv)
       SIMIX_rdv_remove(action->comm.rdv, action);
 
     DEBUG1("SIMIX_comm_finish: action state = %d", action->state);
@@ -465,7 +464,7 @@ void SIMIX_comm_finish(smx_action_t action)
 
       case SIMIX_SRC_HOST_FAILURE:
         TRY {
-          if(req->issuer == action->comm.src_proc)
+          if (req->issuer == action->comm.src_proc)
             THROW0(host_error, 0, "Host failed");
           else
             THROW0(network_error, 0, "Remote peer failed");
@@ -510,19 +509,19 @@ void SIMIX_comm_finish(smx_action_t action)
 void SIMIX_post_comm(smx_action_t action)
 {
   /* Update action state */
-  if(action->comm.src_timeout &&
+  if (action->comm.src_timeout &&
      surf_workstation_model->action_state_get(action->comm.src_timeout) == SURF_ACTION_DONE)
      action->state = SIMIX_SRC_TIMEOUT;
-  else if(action->comm.dst_timeout &&
+  else if (action->comm.dst_timeout &&
           surf_workstation_model->action_state_get(action->comm.dst_timeout) == SURF_ACTION_DONE)
      action->state = SIMIX_DST_TIMEOUT;
-  else if(action->comm.src_timeout &&
+  else if (action->comm.src_timeout &&
           surf_workstation_model->action_state_get(action->comm.src_timeout) == SURF_ACTION_FAILED)
      action->state = SIMIX_SRC_HOST_FAILURE;
-  else if(action->comm.dst_timeout &&
+  else if (action->comm.dst_timeout &&
           surf_workstation_model->action_state_get(action->comm.dst_timeout) == SURF_ACTION_FAILED)
      action->state = SIMIX_DST_HOST_FAILURE;
-  else if(action->comm.surf_comm &&
+  else if (action->comm.surf_comm &&
           surf_workstation_model->action_state_get(action->comm.surf_comm) == SURF_ACTION_FAILED)
      action->state = SIMIX_LINK_FAILURE;
   else
@@ -535,7 +534,7 @@ void SIMIX_post_comm(smx_action_t action)
   SIMIX_comm_destroy_internal_actions(action);
 
   /* If there are requests associated with the action, then answer them */
-  if(xbt_fifo_size(action->request_list))
+  if (xbt_fifo_size(action->request_list))
     SIMIX_comm_finish(action);
 }
 
@@ -719,6 +718,7 @@ void SIMIX_comm_copy_data(smx_action_t comm)
 
   if (buff_size == 0)
     return;
+
   (*SIMIX_comm_copy_data_callback) (comm, buff_size);
 
   /* Set the copied flag so we copy data only once */
index 5cf98a1..cb7d6e7 100644 (file)
@@ -24,8 +24,9 @@ static unsigned long simix_process_count = 0;
  */
 XBT_INLINE smx_process_t SIMIX_process_self(void)
 {
-  if(simix_global)
+  if (simix_global)
     return SIMIX_context_get_data(SIMIX_context_self());
+
   return NULL;
 }
 
@@ -72,7 +73,7 @@ void SIMIX_process_empty_trash(void)
 void SIMIX_create_maestro_process()
 {
   smx_process_t maestro = NULL;
-  
+
   /* Create maestro process and intilialize it */
   maestro = xbt_new0(s_smx_process_t, 1);
   maestro->pid = simix_process_count++;
@@ -82,7 +83,6 @@ void SIMIX_create_maestro_process()
   maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro);
 
   simix_global->maestro_process = maestro;
-  
   return;
 }
 
@@ -129,10 +129,10 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
  */
 smx_process_t SIMIX_process_create(const char *name,
                                    xbt_main_func_t code,
-                                                    void *data,
-                                                          const char *hostname,
-                                                          int argc, char **argv,
-                                                          xbt_dict_t properties) {
+                                  void *data,
+                                  const char *hostname,
+                                  int argc, char **argv,
+                                  xbt_dict_t properties) {
 
   smx_process_t process = NULL;
   smx_host_t host = SIMIX_host_get_by_name(hostname);
@@ -195,7 +195,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t killer) {
   process->blocked = 0;
   process->suspended = 0;
   /* FIXME: set doexception to 0 also? */
-  
+
   if (process->waiting_action) {
 
     switch (process->waiting_action->type) {
@@ -318,25 +318,26 @@ void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
 
     if (process->waiting_action) {
 
-      switch(process->waiting_action->type) {
+      switch (process->waiting_action->type) {
 
         case SIMIX_ACTION_EXECUTE:          
         case SIMIX_ACTION_PARALLEL_EXECUTE:
           SIMIX_host_execution_resume(process->waiting_action);
           break;
-          
+
         case SIMIX_ACTION_COMMUNICATE:
           SIMIX_comm_resume(process->waiting_action);
           break;
-          
+
         case SIMIX_ACTION_SLEEP:
           SIMIX_process_sleep_resume(process->waiting_action);
           break;
-          
+
         default:
           THROW_IMPOSSIBLE;
       }
-    } else {
+    }
+    else {
       xbt_swag_insert(process, simix_global->process_to_run);
     }
   }
@@ -399,7 +400,7 @@ int SIMIX_process_is_suspended(smx_process_t process)
 
 int SIMIX_process_is_enabled(smx_process_t process)
 {
-  if(process->request && SIMIX_request_isEnabled(process->request))
+  if (process->request && SIMIX_request_isEnabled(process->request))
     return TRUE;
 
   return FALSE;
@@ -498,15 +499,15 @@ void SIMIX_process_sleep_resume(smx_action_t action)
 void SIMIX_process_yield(void)
 {
   smx_process_t self = SIMIX_process_self();
-  
+
   DEBUG1("Yield process '%s'", self->name);
-  
+
   /* Go into sleep and return control to maestro */
   SIMIX_context_suspend(self->context);
 
   /* Ok, maestro returned control to us */
   DEBUG1("Maestro returned control to me: '%s'", self->name);
-  
+
   if (self->iwannadie)
     SIMIX_context_stop(self->context);
 
index c6c278a..fd7514d 100644 (file)
@@ -23,14 +23,14 @@ void SIMIX_request_destroy(void)
 void SIMIX_request_push(smx_req_t req)
 {
   req->issuer = SIMIX_process_self();
-  if(req->issuer != simix_global->maestro_process){
+  if (req->issuer != simix_global->maestro_process){
     xbt_os_mutex_acquire(sync_req_vector);
     xbt_dynar_set_as(req_vector, req->issuer->pid, smx_req_t, req);
     xbt_os_mutex_release(sync_req_vector);
     req->issuer->request = req;
     DEBUG2("Yield process '%s' on request of type %d", req->issuer->name, req->call);
     SIMIX_process_yield();
-  }else{
+  } else {
     SIMIX_request_pre(req);
   }
 }
@@ -39,9 +39,9 @@ smx_req_t SIMIX_request_pop(void)
 {
   smx_req_t request = NULL;
   xbt_os_mutex_acquire(sync_req_vector);
-  while(xbt_dynar_length(req_vector)){
+  while (xbt_dynar_length(req_vector)){
     request = xbt_dynar_pop_as(req_vector, smx_req_t);
-    if(request)
+    if (request)
       break;
   }
   xbt_os_mutex_release(sync_req_vector);
@@ -50,7 +50,7 @@ smx_req_t SIMIX_request_pop(void)
 
 void SIMIX_request_answer(smx_req_t req)
 {
-  if(req->issuer != simix_global->maestro_process){
+  if (req->issuer != simix_global->maestro_process){
     req->issuer->request = NULL;    
     xbt_swag_insert(req->issuer, simix_global->process_to_run);
   }
@@ -58,27 +58,28 @@ void SIMIX_request_answer(smx_req_t req)
 
 int SIMIX_request_isVisible(smx_req_t req)
 {
-  if(req->call != REQ_COMM_ISEND && req->call != REQ_COMM_IRECV
-   && req->call != REQ_COMM_WAIT && req->call != REQ_COMM_WAITANY
-   && req->call != REQ_COMM_TEST)
-    return FALSE;
-  return TRUE;
+  return req->call == REQ_COMM_ISEND
+     || req->call == REQ_COMM_IRECV
+     || req->call == REQ_COMM_WAIT
+     || req->call == REQ_COMM_WAITANY
+     || req->call == REQ_COMM_TEST;
 }
 
 int SIMIX_request_isEnabled(smx_req_t req)
 {
   unsigned int index = 0;
   smx_action_t act;
-  
-  switch(req->call){
+
+  switch (req->call) {
+
     case REQ_COMM_WAIT:
-      /*FIXME: check also that src and dst processes are not suspended */
-      if(req->comm_wait.comm->comm.src_proc 
+      /* FIXME: check also that src and dst processes are not suspended */
+      if (req->comm_wait.comm->comm.src_proc 
          && req->comm_wait.comm->comm.dst_proc)
         return TRUE;
       return FALSE;
       break;
-      
+
     case REQ_COMM_WAITANY:
       xbt_dynar_foreach(req->comm_waitany.comms, index, act) {
         if (act->comm.src_proc && act->comm.dst_proc){
@@ -103,38 +104,46 @@ void SIMIX_request_pre(smx_req_t req)
         SIMIX_host_get_by_name(req->host_get_by_name.name);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_NAME:
       req->host_get_name.result =      SIMIX_host_get_name(req->host_get_name.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_PROPERTIES:
       req->host_get_properties.result =
         SIMIX_host_get_properties(req->host_get_properties.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_SPEED:
       req->host_get_speed.result = 
         SIMIX_host_get_speed(req->host_get_speed.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_AVAILABLE_SPEED:
       req->host_get_available_speed.result =
        SIMIX_host_get_available_speed(req->host_get_available_speed.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_STATE:
       req->host_get_state.result = 
         SIMIX_host_get_state(req->host_get_state.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_GET_DATA:
       req->host_get_data.result =      SIMIX_host_get_data(req->host_get_data.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_SET_DATA:
       SIMIX_host_set_data(req->host_set_data.host, req->host_set_data.data);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTE:
       req->host_execute.result = SIMIX_host_execute(
          req->host_execute.name,
@@ -142,6 +151,7 @@ void SIMIX_request_pre(smx_req_t req)
          req->host_execute.computation_amount);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_PARALLEL_EXECUTE:
       req->host_parallel_execute.result = SIMIX_host_parallel_execute(
          req->host_parallel_execute.name,
@@ -153,33 +163,40 @@ void SIMIX_request_pre(smx_req_t req)
          req->host_parallel_execute.rate);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_DESTROY:
       SIMIX_host_execution_destroy(req->host_execution_destroy.execution);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_CANCEL:
       SIMIX_host_execution_cancel(req->host_execution_cancel.execution);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_GET_REMAINS:
       req->host_execution_get_remains.result =
         SIMIX_host_execution_get_remains(req->host_execution_get_remains.execution);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_GET_STATE:
       req->host_execution_get_state.result =
        SIMIX_host_execution_get_state(req->host_execution_get_state.execution);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_SET_PRIORITY:
       SIMIX_host_execution_set_priority(
          req->host_execution_set_priority.execution,
          req->host_execution_set_priority.priority);
       SIMIX_request_answer(req);
       break;
+
     case REQ_HOST_EXECUTION_WAIT:
       SIMIX_pre_host_execution_wait(req);
       break;
+
     case REQ_PROCESS_CREATE:
       req->process_create.result = SIMIX_process_create(
          req->process_create.name,
@@ -191,10 +208,12 @@ void SIMIX_request_pre(smx_req_t req)
          req->process_create.properties);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_KILL:
       SIMIX_process_kill(req->process_kill.process, req->issuer);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_CHANGE_HOST:
       SIMIX_process_change_host(
          req->process_change_host.process,
@@ -202,72 +221,88 @@ void SIMIX_request_pre(smx_req_t req)
          req->process_change_host.dest);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_SUSPEND:
       SIMIX_pre_process_suspend(req);
       break;
+
     case REQ_PROCESS_RESUME:
       SIMIX_process_resume(req->process_resume.process, req->issuer);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_COUNT:
       req->process_count.result = SIMIX_process_count();
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_GET_DATA:
       req->process_get_data.result =
         SIMIX_process_get_data(req->process_get_data.process);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_SET_DATA:
       SIMIX_process_set_data(
          req->process_set_data.process,
          req->process_set_data.data);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_GET_HOST:
       req->process_get_host.result = SIMIX_process_get_host(req->process_get_host.process);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_GET_NAME:
       req->process_get_name.result = SIMIX_process_get_name(req->process_get_name.process);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_IS_SUSPENDED:
       req->process_is_suspended.result =
         SIMIX_process_is_suspended(req->process_is_suspended.process);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_GET_PROPERTIES:
       req->process_get_properties.result =
         SIMIX_process_get_properties(req->process_get_properties.process);
       SIMIX_request_answer(req);
       break;
+
     case REQ_PROCESS_SLEEP:
       SIMIX_pre_process_sleep(req);
       break;
+
     case REQ_RDV_CREATE:
       req->rdv_create.result = SIMIX_rdv_create(req->rdv_create.name);
       SIMIX_request_answer(req);
       break;
+
     case REQ_RDV_DESTROY:
       SIMIX_rdv_destroy(req->rdv_destroy.rdv);
       SIMIX_request_answer(req);
       break;
+
     case REQ_RDV_GEY_BY_NAME:
       req->rdv_get_by_name.result = 
         SIMIX_rdv_get_by_name(req->rdv_get_by_name.name);
       SIMIX_request_answer(req);
       break;
+
     case REQ_RDV_COMM_COUNT_BY_HOST:
       req->rdv_comm_count_by_host.result = SIMIX_rdv_comm_count_by_host(
          req->rdv_comm_count_by_host.rdv,
          req->rdv_comm_count_by_host.host);
       SIMIX_request_answer(req);
       break;
+
     case REQ_RDV_GET_HEAD:
       req->rdv_get_head.result =       SIMIX_rdv_get_head(req->rdv_get_head.rdv);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_ISEND:
       req->comm_isend.result = SIMIX_comm_isend(
          req->issuer,
@@ -279,6 +314,7 @@ void SIMIX_request_pre(smx_req_t req)
          req->comm_isend.data);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_IRECV:
       req->comm_irecv.result = SIMIX_comm_irecv(
          req->issuer,
@@ -287,67 +323,82 @@ void SIMIX_request_pre(smx_req_t req)
          req->comm_irecv.dst_buff_size);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_DESTROY:
       SIMIX_comm_destroy(req->comm_destroy.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_CANCEL:
       SIMIX_comm_cancel(req->comm_cancel.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_WAITANY:
       SIMIX_pre_comm_waitany(req);
       break;
+
     case REQ_COMM_WAIT:
       SIMIX_pre_comm_wait(req);
       break;
+
     case REQ_COMM_TEST:
       SIMIX_pre_comm_test(req);
       break;
+
     case REQ_COMM_GET_REMAINS:
       req->comm_get_remains.result = 
         SIMIX_comm_get_remains(req->comm_get_remains.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_STATE:
       req->comm_get_state.result = 
         SIMIX_comm_get_state(req->comm_get_state.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_DATA:
       req->comm_get_data.result = SIMIX_comm_get_data(req->comm_get_data.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_SRC_BUFF:
       req->comm_get_src_buff.result =
        SIMIX_comm_get_src_buff(req->comm_get_src_buff.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_DST_BUFF:
       req->comm_get_dst_buff.result =
         SIMIX_comm_get_dst_buff(req->comm_get_dst_buff.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_SRC_BUFF_SIZE:
       req->comm_get_src_buff_size.result = 
         SIMIX_comm_get_src_buff_size(req->comm_get_src_buff_size.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_DST_BUFF_SIZE:
       req->comm_get_dst_buff_size.result =
        SIMIX_comm_get_dst_buff_size(req->comm_get_dst_buff_size.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_SRC_PROC:
       req->comm_get_src_proc.result = 
         SIMIX_comm_get_src_proc(req->comm_get_src_proc.comm);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COMM_GET_DST_PROC:
       req->comm_get_dst_proc.result =
         SIMIX_comm_get_dst_proc(req->comm_get_dst_proc.comm);
       SIMIX_request_answer(req);
       break;
+
 #ifdef HAVE_LATENCY_BOUND_TRACKING
     case REQ_COMM_IS_LATENCY_BOUNDED:
       req->comm_is_latency_bounded.result =
@@ -355,71 +406,89 @@ void SIMIX_request_pre(smx_req_t req)
       SIMIX_request_answer(req);
       break;
 #endif
+
     case REQ_MUTEX_INIT:
       req->mutex_init.result = SIMIX_mutex_init();
       SIMIX_request_answer(req);
       break;
+
     case REQ_MUTEX_DESTROY:
       SIMIX_mutex_destroy(req->mutex_destroy.mutex);
       SIMIX_request_answer(req);
       break;
+
     case REQ_MUTEX_LOCK:
       SIMIX_pre_mutex_lock(req);
       break;
+
     case REQ_MUTEX_TRYLOCK:
       req->mutex_trylock.result =
              SIMIX_mutex_trylock(req->mutex_trylock.mutex, req->issuer);
       SIMIX_request_answer(req);
       break;
+
     case REQ_MUTEX_UNLOCK:
       SIMIX_mutex_unlock(req->mutex_unlock.mutex, req->issuer);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COND_INIT:
       req->cond_init.result = SIMIX_cond_init();
       SIMIX_request_answer(req);
       break;
+
     case REQ_COND_DESTROY:
       SIMIX_cond_destroy(req->cond_destroy.cond);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COND_SIGNAL:
       SIMIX_cond_signal(req->cond_signal.cond);
       SIMIX_request_answer(req);
       break;
+
     case REQ_COND_WAIT:
       SIMIX_pre_cond_wait(req);
       break;
+
     case REQ_COND_WAIT_TIMEOUT:
       SIMIX_pre_cond_wait_timeout(req);
       break;
+
     case REQ_COND_BROADCAST:
       SIMIX_cond_broadcast(req->cond_broadcast.cond);
       SIMIX_request_answer(req);
       break;
+
     case REQ_SEM_INIT:
       req->sem_init.result = SIMIX_sem_init(req->sem_init.capacity);
       SIMIX_request_answer(req);
       break;
+
     case REQ_SEM_DESTROY:
       SIMIX_sem_destroy(req->sem_destroy.sem);
       SIMIX_request_answer(req);
       break;
+
     case REQ_SEM_RELEASE:
       SIMIX_sem_release(req->sem_release.sem);
       SIMIX_request_answer(req);
       break;
+
     case REQ_SEM_WOULD_BLOCK:
       req->sem_would_block.result =
        SIMIX_sem_would_block(req->sem_would_block.sem);
       SIMIX_request_answer(req);
       break;
+
     case REQ_SEM_ACQUIRE:
       SIMIX_pre_sem_acquire(req);
       break;
+
     case REQ_SEM_ACQUIRE_TIMEOUT:
       SIMIX_pre_sem_acquire_timeout(req);
       break;
+
     case REQ_SEM_GET_CAPACITY:
       req->sem_get_capacity.result = 
         SIMIX_sem_get_capacity(req->sem_get_capacity.sem);
@@ -430,20 +499,25 @@ void SIMIX_request_pre(smx_req_t req)
 
 void SIMIX_request_post(smx_action_t action)
 {
-  switch(action->type) {
+  switch (action->type) {
+
     case SIMIX_ACTION_EXECUTE:
     case SIMIX_ACTION_PARALLEL_EXECUTE:
       SIMIX_post_host_execute(action);
       break;
+
     case SIMIX_ACTION_COMMUNICATE:
       SIMIX_post_comm(action);
       break;
+
     case SIMIX_ACTION_SLEEP:
       SIMIX_post_process_sleep(action);
       break;
+
     case SIMIX_ACTION_SYNCHRO:
       SIMIX_post_synchro(action);
       break;
+
     case SIMIX_ACTION_IO:
       break;
   }
index 059ca6d..7f6fae4 100644 (file)
@@ -75,10 +75,10 @@ void SIMIX_synchro_destroy(smx_action_t action)
 
 void SIMIX_post_synchro(smx_action_t action)
 {
-  if(surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_FAILED)
-     action->state = SIMIX_FAILED;
+  if (surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_FAILED)
+    action->state = SIMIX_FAILED;
   else if(surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_DONE)
-     action->state = SIMIX_SRC_TIMEOUT;
+    action->state = SIMIX_SRC_TIMEOUT;
 
   action->synchro.sleep->model_type->action_unref(action->synchro.sleep);
 
@@ -88,8 +88,9 @@ void SIMIX_post_synchro(smx_action_t action)
 static void SIMIX_synchro_finish(smx_action_t action)
 {
   smx_req_t req = xbt_fifo_shift(action->request_list);
-  
-  switch(action->state){
+
+  switch (action->state) {
+
     case SIMIX_SRC_TIMEOUT:
       TRY {
         THROW0(timeout_error, 0, "Synchro's wait timeout");
@@ -105,7 +106,7 @@ static void SIMIX_synchro_finish(smx_action_t action)
         req->issuer->doexception = 1;
       }
       break;
-      
+
     default:
       THROW_IMPOSSIBLE;
       break;
@@ -139,11 +140,11 @@ smx_mutex_t SIMIX_mutex_init(void)
  */
 void SIMIX_pre_mutex_lock(smx_req_t req)
 {
-  /*FIXME: check where to validate the arguments */
+  /* FIXME: check where to validate the arguments */
   smx_action_t sync_act = NULL;
   smx_mutex_t mutex = req->mutex_lock.mutex;
   smx_process_t process = req->issuer;
-  
+
   if (mutex->locked) {
     /* FIXME: check if the host is active ? */
     /* Somebody using the mutex, use a synchro action to get host failures */
@@ -172,11 +173,10 @@ int SIMIX_mutex_trylock(smx_mutex_t mutex, smx_process_t issuer)
 {
   if (mutex->locked)
     return 0;
-  else {
-    mutex->locked = 1;
-    mutex->owner = issuer;
-    return 1;
-  }
+
+  mutex->locked = 1;
+  mutex->owner = issuer;
+  return 1;
 }
 
 /**
@@ -193,9 +193,9 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer)
   smx_process_t p;              /*process to wake up */
 
   /* If the mutex is not owned by the issuer do nothing */
-  if(issuer != mutex->owner)
+  if (issuer != mutex->owner)
     return;
-  
+
   if (xbt_swag_size(mutex->sleeping) > 0) {
     p = xbt_swag_extract(mutex->sleeping);
     SIMIX_synchro_destroy(p->waiting_action);
@@ -217,7 +217,7 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer)
  */
 void SIMIX_mutex_destroy(smx_mutex_t mutex)
 {
-  if(mutex){
+  if (mutex){
     xbt_swag_free(mutex->sleeping);
     xbt_free(mutex);
   }
@@ -264,7 +264,7 @@ void SIMIX_pre_cond_wait_timeout(smx_req_t req)
   smx_cond_t cond = req->cond_wait_timeout.cond;
   smx_mutex_t mutex = req->cond_wait_timeout.mutex;
   double timeout = req->cond_wait_timeout.timeout;
-  
+
   _SIMIX_cond_wait(cond, mutex, timeout, issuer, req);
 }
 
@@ -273,11 +273,11 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
                              smx_process_t issuer, smx_req_t req)
 {
   smx_action_t sync_act = NULL;
-  
+
   DEBUG1("Wait condition %p", cond);
-  
+
   /* If there is a mutex unlock it */
-  /* FIXME: what happen if the issuer is not the owner of the mutex ? */
+  /* FIXME: what happens if the issuer is not the owner of the mutex? */
   if (mutex != NULL) {
     cond->mutex = mutex;
     SIMIX_mutex_unlock(mutex, issuer);
@@ -301,13 +301,13 @@ void SIMIX_cond_signal(smx_cond_t cond)
   smx_process_t proc = NULL;
   smx_mutex_t mutex = NULL;
   smx_req_t req = NULL;
-  
+
   DEBUG1("Signal condition %p", cond);
 
   /* If there are processes waiting for the condition choose one and try 
      to make it acquire the mutex */
   if ((proc = xbt_swag_extract(cond->sleeping))) {
-    
+
     /* Destroy waiter's synchro action */
     SIMIX_synchro_destroy(proc->waiting_action);
     proc->waiting_action = NULL;
@@ -321,7 +321,7 @@ void SIMIX_cond_signal(smx_cond_t cond)
 
     req->call = REQ_MUTEX_LOCK;
     req->mutex_lock.mutex = mutex;
-    
+
     SIMIX_pre_mutex_lock(req);
   }
 }
@@ -338,7 +338,7 @@ void SIMIX_cond_broadcast(smx_cond_t cond)
   DEBUG1("Broadcast condition %p", cond);
 
   /* Signal the condition until nobody is waiting on it */
-  while(xbt_swag_size(cond->sleeping)){
+  while (xbt_swag_size(cond->sleeping)) {
     SIMIX_cond_signal(cond);
   }
 }
@@ -353,13 +353,12 @@ void SIMIX_cond_destroy(smx_cond_t cond)
 {
   DEBUG1("Destroy condition %p", cond);
 
-  if (cond != NULL){
+  if (cond != NULL) {
     xbt_assert0(xbt_swag_size(cond->sleeping) == 0,
                 "Cannot destroy conditional since someone is still using it");
 
     xbt_swag_free(cond->sleeping);
     xbt_free(cond);
-    return;
   }
 }
 
@@ -380,7 +379,7 @@ smx_sem_t SIMIX_sem_init(unsigned int value)
 void SIMIX_sem_destroy(smx_sem_t sem)
 {
   DEBUG1("Destroy semaphore %p", sem);
-  if (sem != NULL){
+  if (sem != NULL) {
     xbt_assert0(xbt_swag_size(sem->sleeping) == 0,
                 "Cannot destroy semaphore since someone is still using it");
     xbt_swag_free(sem->sleeping);
@@ -392,18 +391,18 @@ void SIMIX_sem_destroy(smx_sem_t sem)
  *
  * Unlock a process waiting on the semaphore.
  * If no one was blocked, the semaphore capacity is increased by 1.
- * */
+ */
 void SIMIX_sem_release(smx_sem_t sem)
 {
   smx_process_t proc;
-  
+
   DEBUG1("Sem release semaphore %p", sem);
   if ((proc = xbt_swag_extract(sem->sleeping))) {
     proc = xbt_swag_extract(sem->sleeping);
     SIMIX_synchro_destroy(proc->waiting_action);
     proc->waiting_action = NULL;
     SIMIX_request_answer(proc->request);
-  }else if(sem->value < SMX_SEM_NOLIMIT){
+  } else if (sem->value < SMX_SEM_NOLIMIT) {
     sem->value++;
   }
 }
@@ -424,14 +423,14 @@ static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
                             smx_req_t req)
 {
   smx_action_t sync_act = NULL;
-  
+
   DEBUG2("Wait semaphore %p (timeout:%f)", sem, timeout);
-  if(sem->value <= 0){
+  if (sem->value <= 0) {
     sync_act = SIMIX_synchro_wait(issuer->smx_host, timeout);
     xbt_fifo_unshift(sync_act->request_list, req);
     issuer->waiting_action = sync_act;
     xbt_swag_insert(issuer, sem->sleeping);
-  }else{
+  } else {
     sem->value--;
     SIMIX_request_answer(req);
   }
index ea732ee..182c562 100644 (file)
@@ -527,10 +527,10 @@ e_smx_state_t SIMIX_req_process_sleep(double duration)
 smx_rdv_t SIMIX_req_rdv_create(const char *name)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_CREATE;
   req.rdv_create.name = name;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_create.result;
 }
@@ -543,10 +543,10 @@ smx_rdv_t SIMIX_req_rdv_create(const char *name)
 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_DESTROY; 
   req.rdv_destroy.rdv = rdv;
-  
+
   SIMIX_request_push(&req);
 }
 
@@ -570,11 +570,11 @@ smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_COMM_COUNT_BY_HOST; 
   req.rdv_comm_count_by_host.rdv = rdv;
   req.rdv_comm_count_by_host.host = host;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_comm_count_by_host.result;
 }
@@ -587,10 +587,10 @@ int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_GET_HEAD; 
   req.rdv_get_head.rdv = rdv;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_get_head.result;
 }
@@ -609,7 +609,7 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
   req.comm_isend.src_buff = src_buff;
   req.comm_isend.src_buff_size = src_buff_size;
   req.comm_isend.data = data;
-  
+
   SIMIX_request_push(&req);
   return req.comm_isend.result;
 }
@@ -632,30 +632,30 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
 void SIMIX_req_comm_destroy(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_DESTROY;
   req.comm_destroy.comm = comm;
-  
+
   SIMIX_request_push(&req);
 }
 
 void SIMIX_req_comm_cancel(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_CANCEL;
   req.comm_cancel.comm = comm;
-  
+
   SIMIX_request_push(&req);
 }
 
 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_WAITANY;
   req.comm_waitany.comms = comms;
-  
+
   SIMIX_request_push(&req);
   return req.comm_waitany.result;
 }
@@ -663,21 +663,21 @@ unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_WAIT;
   req.comm_wait.comm = comm;
   req.comm_wait.timeout = timeout;
-  
+
   SIMIX_request_push(&req);
 }
 
 int SIMIX_req_comm_test(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_TEST;
   req.comm_test.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_test.result;
 }
@@ -685,10 +685,10 @@ int SIMIX_req_comm_test(smx_action_t comm)
 double SIMIX_req_comm_get_remains(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_REMAINS;
   req.comm_get_remains.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_remains.result;
 }
@@ -696,10 +696,10 @@ double SIMIX_req_comm_get_remains(smx_action_t comm)
 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_STATE;
   req.comm_get_state.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_state.result;
 }
@@ -707,10 +707,10 @@ e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
 void *SIMIX_req_comm_get_data(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DATA;
   req.comm_get_data.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_data.result;
 }
@@ -718,10 +718,10 @@ void *SIMIX_req_comm_get_data(smx_action_t comm)
 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_BUFF;
   req.comm_get_src_buff.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_buff.result;
 }
@@ -729,10 +729,10 @@ void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_BUFF;
   req.comm_get_dst_buff.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_buff.result;
 }
@@ -740,10 +740,10 @@ void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_BUFF_SIZE;
   req.comm_get_src_buff_size.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_buff_size.result;
 }
@@ -751,10 +751,10 @@ size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_BUFF_SIZE;
   req.comm_get_dst_buff_size.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_buff_size.result;
 }
@@ -762,10 +762,10 @@ size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_PROC;
   req.comm_get_src_proc.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_proc.result;
 }
@@ -773,10 +773,10 @@ smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_PROC;
   req.comm_get_dst_proc.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_proc.result;
 }
@@ -888,8 +888,8 @@ void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
 }
 
 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
-                                         smx_mutex_t mutex,
-                                         double timeout)
+                                 smx_mutex_t mutex,
+                                 double timeout)
 {
   s_smx_req_t req;
 
index cd16d9f..a820073 100644 (file)
@@ -44,4 +44,5 @@ int SIMIX_sem_would_block(smx_sem_t sem);
 void SIMIX_pre_sem_acquire(smx_req_t req);
 void SIMIX_pre_sem_acquire_timeout(smx_req_t req);
 int SIMIX_sem_get_capacity(smx_sem_t sem);
+
 #endif