Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some tests done and bugs corrected.
authordonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Mar 2007 13:38:57 +0000 (13:38 +0000)
committerdonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Mar 2007 13:38:57 +0000 (13:38 +0000)
Removed SIMIX_error_t.
Added new privates variables in the header ( action and process ).

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

src/include/simix/datatypes.h
src/include/simix/simix.h
src/simix/private.h
src/simix/smx_action.c
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_process.c
src/simix/smx_synchro.c

index 4557bfd..abaaf31 100644 (file)
@@ -92,27 +92,5 @@ typedef struct s_smx_process *smx_process_t;
 typedef int(*smx_process_code_t)(int argc,char *argv[]) ;
 /** @} */
 
 typedef int(*smx_process_code_t)(int argc,char *argv[]) ;
 /** @} */
 
-
-/* ***************************** Error handling ***************************** */
-/** @brief Error handling 
-    @ingroup m_datatypes_management 
-    @{
-*/
-typedef enum {
-  SIMIX_OK = 0,  /**< @brief Everything is right. Keep on going this way ! */
-  SIMIX_WARNING, /**< @brief Mmmh! Something must be not perfectly clean. But I
-      may be a paranoid freak... ! */
-  SIMIX_TRANSFER_FAILURE, /**< @brief There has been a problem during you action
-      transfer. Either the network is down or the remote host has been
-      shutdown. */
-  SIMIX_HOST_FAILURE, /**< @brief System shutdown. The host on which you are
-      running has just been rebooted. Free your datastructures and
-      return now !*/
-  SIMIX_ACTION_CANCELLED, /**< @brief Cancelled action. This action has been cancelled 
-                       by somebody!*/
-  SIMIX_FATAL /**< @brief You've done something wrong. You'd better look at it... */
-} SIMIX_error_t;
-/** @} */
-
 SG_END_DECL()
 #endif
 SG_END_DECL()
 #endif
index 20a656d..ccafb75 100644 (file)
@@ -19,8 +19,8 @@ SG_BEGIN_DECL()
 XBT_PUBLIC(void) SIMIX_config(const char *name, ...);
 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
 XBT_PUBLIC(void) SIMIX_global_init_args(int *argc, char **argv);
 XBT_PUBLIC(void) SIMIX_config(const char *name, ...);
 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
 XBT_PUBLIC(void) SIMIX_global_init_args(int *argc, char **argv);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_main(void);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_clean(void);
+XBT_PUBLIC(void) SIMIX_main(void);
+XBT_PUBLIC(void) SIMIX_clean(void);
 XBT_PUBLIC(void) SIMIX_function_register(const char *name, smx_process_code_t code);
 XBT_PUBLIC(smx_process_code_t) SIMIX_get_registered_function(const char *name);
 // SIMIX_deploy_application???
 XBT_PUBLIC(void) SIMIX_function_register(const char *name, smx_process_code_t code);
 XBT_PUBLIC(smx_process_code_t) SIMIX_get_registered_function(const char *name);
 // SIMIX_deploy_application???
@@ -30,7 +30,7 @@ XBT_PUBLIC(double) SIMIX_get_clock(void);
 
 /************************** Host handling ***********************************/
 //pointer to above layer
 
 /************************** Host handling ***********************************/
 //pointer to above layer
-XBT_PUBLIC(SIMIX_error_t) SIMIX_host_set_data(smx_host_t host, void *data);
+XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
 
 XBT_PUBLIC(const char *) SIMIX_host_get_name(smx_host_t host);
 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
 
 XBT_PUBLIC(const char *) SIMIX_host_get_name(smx_host_t host);
@@ -55,21 +55,22 @@ XBT_PUBLIC(smx_process_t) SIMIX_process_create_with_arguments(const char *name,
 XBT_PUBLIC(void) SIMIX_process_kill(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_killall(void);
 
 XBT_PUBLIC(void) SIMIX_process_kill(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_killall(void);
 
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_change_host(smx_process_t process, smx_host_t host);
+XBT_PUBLIC(void) SIMIX_process_change_host(smx_process_t process, smx_host_t host);
 //above layer
 XBT_PUBLIC(void*) SIMIX_process_get_data(smx_process_t process);
 //above layer
 XBT_PUBLIC(void*) SIMIX_process_get_data(smx_process_t process);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_set_data(smx_process_t process, void *data);
+XBT_PUBLIC(void) SIMIX_process_set_data(smx_process_t process, void *data);
 
 XBT_PUBLIC(smx_host_t) SIMIX_process_get_host(smx_process_t process);
 XBT_PUBLIC(const char *)SIMIX_process_get_name(smx_process_t process);
 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
 
 
 XBT_PUBLIC(smx_host_t) SIMIX_process_get_host(smx_process_t process);
 XBT_PUBLIC(const char *)SIMIX_process_get_name(smx_process_t process);
 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
 
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_suspend(smx_process_t process);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_resume(smx_process_t process);
+XBT_PUBLIC(void) SIMIX_process_suspend(smx_process_t process);
+XBT_PUBLIC(void) SIMIX_process_resume(smx_process_t process);
 XBT_PUBLIC(int) SIMIX_process_is_suspended(smx_process_t process);
 
 XBT_PUBLIC(int) SIMIX_process_is_suspended(smx_process_t process);
 
-XBT_PUBLIC(SIMIX_error_t) SIMIX_process_sleep(double nb_sec);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_get_errno(void);
+XBT_PUBLIC(void) SIMIX_process_sleep(double nb_sec);
+//XBT_PUBLIC(void) SIMIX_get_errno(void);
+
 
 /************************** Synchro handling **********************************/
 
 
 /************************** Synchro handling **********************************/
 
@@ -78,7 +79,7 @@ XBT_PUBLIC(smx_mutex_t) SIMIX_mutex_init(void);
 XBT_PUBLIC(void) SIMIX_mutex_lock(smx_mutex_t mutex);
 XBT_PUBLIC(int) SIMIX_mutex_trylock(smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_mutex_unlock(smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_mutex_lock(smx_mutex_t mutex);
 XBT_PUBLIC(int) SIMIX_mutex_trylock(smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_mutex_unlock(smx_mutex_t mutex);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_mutex_destroy(smx_mutex_t mutex);
+XBT_PUBLIC(void) SIMIX_mutex_destroy(smx_mutex_t mutex);
 
 /*****Conditional*****/
 XBT_PUBLIC(smx_cond_t) SIMIX_cond_init(void);
 
 /*****Conditional*****/
 XBT_PUBLIC(smx_cond_t) SIMIX_cond_init(void);
@@ -86,15 +87,15 @@ XBT_PUBLIC(void) SIMIX_cond_signal(smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_cond_wait(smx_cond_t cond,smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, double max_duration);
 XBT_PUBLIC(void) SIMIX_cond_broadcast(smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_cond_wait(smx_cond_t cond,smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, double max_duration);
 XBT_PUBLIC(void) SIMIX_cond_broadcast(smx_cond_t cond);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_cond_destroy(smx_cond_t cond);
+XBT_PUBLIC(void) SIMIX_cond_destroy(smx_cond_t cond);
 
 
 /************************** Action handling ************************************/
 XBT_PUBLIC(smx_action_t) SIMIX_communicate(smx_host_t sender,smx_host_t receiver, char *name, double size, double rate);
 XBT_PUBLIC(smx_action_t) SIMIX_execute(smx_host_t host,char *name, double amount);
 
 
 /************************** Action handling ************************************/
 XBT_PUBLIC(smx_action_t) SIMIX_communicate(smx_host_t sender,smx_host_t receiver, char *name, double size, double rate);
 XBT_PUBLIC(smx_action_t) SIMIX_execute(smx_host_t host,char *name, double amount);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_action_cancel(smx_action_t action);
+XBT_PUBLIC(void) SIMIX_action_cancel(smx_action_t action);
 XBT_PUBLIC(void) SIMIX_action_set_priority(smx_action_t action, double priority);
 XBT_PUBLIC(void) SIMIX_action_set_priority(smx_action_t action, double priority);
-XBT_PUBLIC(SIMIX_error_t) SIMIX_action_destroy(smx_action_t action);
+XBT_PUBLIC(void) SIMIX_action_destroy(smx_action_t action);
 XBT_PUBLIC(void) SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_register_condition_to_action(smx_action_t action, smx_cond_t cond);
 
 XBT_PUBLIC(void) SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_register_condition_to_action(smx_action_t action, smx_cond_t cond);
 
index 6ee5adb..293b0a0 100644 (file)
@@ -12,7 +12,6 @@
 #include "simix/simix.h"
 #include "surf/surf.h"
 #include "xbt/fifo.h"
 #include "simix/simix.h"
 #include "surf/surf.h"
 #include "xbt/fifo.h"
-#include "xbt/dynar.h"
 #include "xbt/swag.h"
 #include "xbt/dict.h"
 #include "xbt/context.h"
 #include "xbt/swag.h"
 #include "xbt/dict.h"
 #include "xbt/context.h"
@@ -57,7 +56,7 @@ typedef struct s_simdata_process {
   smx_action_t block_action;   /* action that block the process when it does a mutex_lock or cond_wait */
   int argc;                     /* arguments number if any */
   char **argv;                  /* arguments table if any */
   smx_action_t block_action;   /* action that block the process when it does a mutex_lock or cond_wait */
   int argc;                     /* arguments number if any */
   char **argv;                  /* arguments table if any */
-  SIMIX_error_t last_errno;       /* the last value returned by a MSG_function */
+//  SIMIX_error_t last_errno;       /* the last value returned by a MSG_function */
 // int paje_state;               /* the number of states stacked with Paje */
 } s_simdata_process_t;
 
 // int paje_state;               /* the number of states stacked with Paje */
 } s_simdata_process_t;
 
@@ -92,21 +91,13 @@ typedef struct s_simdata_action {
   surf_action_t surf_action;   /* SURF modeling of computation  */
   
   xbt_fifo_t cond_list;                /* conditional variables that must be signaled when the action finish. */
   surf_action_t surf_action;   /* SURF modeling of computation  */
   
   xbt_fifo_t cond_list;                /* conditional variables that must be signaled when the action finish. */
-  smx_host_t source;
-/*
-  double priority;
-  double rate;
-*/  
-  /*int using;*/
-
-  /*******  Parallel Tasks Only !!!! *******/
-  /*
-  int host_nb;
-  void * *host_list;            *//* SURF modeling */
-  /*
-  double *comp_amount;
-  double *comm_amount;
-  */
+  smx_host_t source; 
+
+/* control needed when the action blocks a process(__SIMIX_process_block). For each process that is blocked a new action is created, the process is stocked in cond_process variable and the "boolean" action_block is marked to 1 */
+  int action_block;            /* simix control variable, system action or not */
+  smx_process_t cond_process;  /* system process will wake up */               
+  smx_cond_t timeout_cond;     /* useful to remove the process from the sleeping list when a timeout occurs */
+
 } s_simdata_action_t;
 
 
 } s_simdata_action_t;
 
 
@@ -125,9 +116,9 @@ extern xbt_cfg_t _simix_cfg_set;
 
 
 
 
 
 
-#define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
-#define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
-#define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
+//#define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
+//#define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
+//#define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
 
 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
 
 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
@@ -138,12 +129,12 @@ smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
 void __SIMIX_host_destroy(smx_host_t host);
 
 int __SIMIX_process_block(double max_duration);
 void __SIMIX_host_destroy(smx_host_t host);
 
 int __SIMIX_process_block(double max_duration);
-SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
+void __SIMIX_process_unblock(smx_process_t process);
 int __SIMIX_process_isBlocked(smx_process_t process);
 
 void __SIMIX_display_process_status(void);
 
 int __SIMIX_process_isBlocked(smx_process_t process);
 
 void __SIMIX_display_process_status(void);
 
-SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
+void __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
 
 
 /*
 
 
 /*
index dc09c63..dbde453 100644 (file)
@@ -24,8 +24,10 @@ smx_action_t SIMIX_communicate(smx_host_t sender,smx_host_t receiver,char * name
        simdata->cond_list = xbt_fifo_new();
        
        /* initialize them */
        simdata->cond_list = xbt_fifo_new();
        
        /* initialize them */
-       act-> name = xbt_strdup(name);
-
+       act->name = xbt_strdup(name);
+       simdata->action_block=0;
+       simdata->cond_process=NULL;
+       simdata->timeout_cond = NULL;
 
 
        simdata->surf_action = surf_workstation_resource->extension_public->
 
 
        simdata->surf_action = surf_workstation_resource->extension_public->
@@ -48,6 +50,9 @@ smx_action_t SIMIX_execute(smx_host_t host, char * name, double amount)
        /* initialize them */
        simdata->source = host;
        act-> name = xbt_strdup(name);
        /* initialize them */
        simdata->source = host;
        act-> name = xbt_strdup(name);
+       simdata->action_block=0;
+       simdata->cond_process=NULL;
+       simdata->timeout_cond = NULL;
 
        /* set communication */
        simdata->surf_action = surf_workstation_resource->extension_public->
 
        /* set communication */
        simdata->surf_action = surf_workstation_resource->extension_public->
@@ -58,15 +63,14 @@ smx_action_t SIMIX_execute(smx_host_t host, char * name, double amount)
        return act;
 }
 
        return act;
 }
 
-SIMIX_error_t SIMIX_action_cancel(smx_action_t action)
+void SIMIX_action_cancel(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
 
   if(action->simdata->surf_action) {
     surf_workstation_resource->common_public->action_cancel(action->simdata->surf_action);
 {
   xbt_assert0((action != NULL), "Invalid parameter");
 
   if(action->simdata->surf_action) {
     surf_workstation_resource->common_public->action_cancel(action->simdata->surf_action);
-    return SIMIX_OK;
   }
   }
-  return SIMIX_FATAL;
+  return;
 }
 
 void SIMIX_action_set_priority(smx_action_t action, double priority)
 }
 
 void SIMIX_action_set_priority(smx_action_t action, double priority)
@@ -78,13 +82,13 @@ void SIMIX_action_set_priority(smx_action_t action, double priority)
        return;
 }
 
        return;
 }
 
-SIMIX_error_t SIMIX_action_destroy(smx_action_t action)
+void SIMIX_action_destroy(smx_action_t action)
 {
 
        xbt_assert0((action != NULL), "Invalid parameter");
 
 {
 
        xbt_assert0((action != NULL), "Invalid parameter");
 
-       xbt_assert0((xbt_fifo_size(action->simdata->cond_list)==0), 
-                       "Conditional list not empty. There is a problem. Cannot destroy it now!");
+       xbt_assert1((xbt_fifo_size(action->simdata->cond_list)==0), 
+                       "Conditional list not empty %d. There is a problem. Cannot destroy it now!", xbt_fifo_size(action->simdata->cond_list));
 
        if(action->name) free(action->name);
 
 
        if(action->name) free(action->name);
 
@@ -93,7 +97,7 @@ SIMIX_error_t SIMIX_action_destroy(smx_action_t action)
        if(action->simdata->surf_action) 
                action->simdata->surf_action->resource_type->common_public->action_free(action->simdata->surf_action);
 
        if(action->simdata->surf_action) 
                action->simdata->surf_action->resource_type->common_public->action_free(action->simdata->surf_action);
 
-       return SIMIX_OK;
+       return;
 }
 
 void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
 }
 
 void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
@@ -103,7 +107,7 @@ void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
        xbt_fifo_push(cond->actions,action);
 }
 
        xbt_fifo_push(cond->actions,action);
 }
 
-SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action)
+void __SIMIX_wait_for_action(smx_process_t process, smx_action_t action)
 {
        e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
        simdata_action_t simdata = action->simdata;
 {
        e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
        simdata_action_t simdata = action->simdata;
@@ -121,17 +125,15 @@ SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action
        if(state == SURF_ACTION_DONE) {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
        if(state == SURF_ACTION_DONE) {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
-               SIMIX_RETURN(SIMIX_OK);
        } else if(surf_workstation_resource->extension_public->
                        get_state(SIMIX_process_get_host(process)->simdata->host) 
                        == SURF_CPU_OFF) {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
        } else if(surf_workstation_resource->extension_public->
                        get_state(SIMIX_process_get_host(process)->simdata->host) 
                        == SURF_CPU_OFF) {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
-               SIMIX_RETURN(SIMIX_HOST_FAILURE);
        } else {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
        } else {
                if(surf_workstation_resource->common_public->action_free(simdata->surf_action)) 
                        simdata->surf_action = NULL;
-               SIMIX_RETURN(SIMIX_ACTION_CANCELLED);
        }
        }
+       return;
 
 }
 
 }
index e8c5bee..c35edaf 100644 (file)
@@ -49,7 +49,7 @@ void SIMIX_global_init(int *argc, char **argv)
 
                xbt_context_init();
                simix_global->host = xbt_fifo_new();
 
                xbt_context_init();
                simix_global->host = xbt_fifo_new();
-               simix_global->process_to_run = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
+               simix_global->process_to_run = xbt_swag_new(xbt_swag_offset(proc,synchro_hookup));
                simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
                simix_global->current_process = NULL;
                simix_global->registered_functions = xbt_dict_new();
                simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
                simix_global->current_process = NULL;
                simix_global->registered_functions = xbt_dict_new();
@@ -96,7 +96,7 @@ static void _XBT_CALL inthandler(int ignored)
 /** \ingroup msg_simulation
  * \brief Launch the SIMIX simulation
  */
 /** \ingroup msg_simulation
  * \brief Launch the SIMIX simulation
  */
-SIMIX_error_t SIMIX_main(void)
+void SIMIX_main(void)
 {
        smx_process_t process = NULL;
        smx_cond_t cond = NULL;
 {
        smx_process_t process = NULL;
        smx_cond_t cond = NULL;
@@ -191,11 +191,20 @@ SIMIX_error_t SIMIX_main(void)
                                                xbt_fifo_item_t _cursor;
 
                                                DEBUG1("** %s failed **",smx_action->name);
                                                xbt_fifo_item_t _cursor;
 
                                                DEBUG1("** %s failed **",smx_action->name);
-                                               xbt_fifo_foreach(smx_action->simdata->cond_list,_cursor,cond,smx_cond_t) {
-                                                       SIMIX_cond_broadcast(cond);
-                                                       xbt_swag_foreach(process,cond->sleeping) {
-                                                               DEBUG2("\t preparing to wake up %s on %s",           
-                                                                               process->name,  process->simdata->host->name);
+                                               /* put all the process that are waiting in a conditional (dummy action) on the process_to_run list */
+                                               if ( smx_action->simdata->action_block) {
+                                                                       xbt_swag_insert(smx_action->simdata->cond_process,simix_global->process_to_run);
+                                               }
+                                               /* else, do the dummy action finish, call the signal broadcast */
+                                               else {
+                                                       xbt_fifo_foreach(smx_action->simdata->cond_list,_cursor,cond,smx_cond_t) {
+                                                               xbt_swag_foreach(process,cond->sleeping) {
+                                                                       DEBUG2("\t preparing to wake up %s on %s",           
+                                                                                       process->name,  process->simdata->host->name);
+                                                               }
+                                                               SIMIX_cond_broadcast(cond);
+                                                               /* remove conditional from action */
+                                                               xbt_fifo_remove(smx_action->simdata->cond_list,cond);
                                                        }
                                                }
                                                process=NULL;                                           
                                                        }
                                                }
                                                process=NULL;                                           
@@ -205,6 +214,35 @@ SIMIX_error_t SIMIX_main(void)
                                                        xbt_swag_extract(resource->common_public->states.
                                                                done_action_set))) {
                                        smx_action = action->data;
                                                        xbt_swag_extract(resource->common_public->states.
                                                                done_action_set))) {
                                        smx_action = action->data;
+                                       if (smx_action) {
+                                               xbt_fifo_item_t _cursor;
+
+                                               DEBUG1("** %s done **",smx_action->name);
+                                               /* put all the process that are waiting in a conditional (dummy action) on the process_to_run list */
+                                               if ( smx_action->simdata->action_block) {
+                                                       if (smx_action->simdata->timeout_cond) {
+                                                               xbt_swag_remove(smx_action->simdata->cond_process,smx_action->simdata->timeout_cond->sleeping);
+                                                       }
+                                                       process = smx_action->simdata->cond_process;
+                                                       xbt_swag_insert(smx_action->simdata->cond_process,simix_global->process_to_run);
+                                                       DEBUG2("\t preparing to wake up %s on %s",           
+                                                                       process->name,  process->simdata->host->name);
+                                               }
+                                               /* else, do the dummy action finish, call the signal broadcast */
+                                               else {
+                                                       xbt_fifo_foreach(smx_action->simdata->cond_list,_cursor,cond,smx_cond_t) {
+                                                               xbt_swag_foreach(process,cond->sleeping) {
+                                                                       DEBUG2("\t preparing to wake up %s on %s",           
+                                                                                       process->name,  process->simdata->host->name);
+                                                               }
+                                                               SIMIX_cond_broadcast(cond);
+                                                               /* remove conditional from action */
+                                                               xbt_fifo_remove(smx_action->simdata->cond_list,cond);
+                                                       }
+                                               }
+                                               process=NULL;                                           
+                                       }
+/*
                                        if (smx_action) {
                                                xbt_fifo_item_t _cursor;
 
                                        if (smx_action) {
                                                xbt_fifo_item_t _cursor;
 
@@ -217,7 +255,7 @@ SIMIX_error_t SIMIX_main(void)
                                                        }
                                                }
                                                process=NULL;                                           
                                                        }
                                                }
                                                process=NULL;                                           
-                                       }
+                                       }*/
 
                                }
                        }
 
                                }
                        }
@@ -227,7 +265,7 @@ SIMIX_error_t SIMIX_main(void)
 
        if (xbt_swag_size(simix_global->process_list) == 0) {
                INFO0("Congratulations ! Simulation terminated : all processes are over");
 
        if (xbt_swag_size(simix_global->process_list) == 0) {
                INFO0("Congratulations ! Simulation terminated : all processes are over");
-               return SIMIX_OK;
+               return;
        } else {
                INFO0("Oops ! Deadlock or code not perfectly clean.");
                __SIMIX_display_process_status();
        } else {
                INFO0("Oops ! Deadlock or code not perfectly clean.");
                __SIMIX_display_process_status();
@@ -238,7 +276,7 @@ SIMIX_error_t SIMIX_main(void)
                }
 
                INFO0("Return a Warning.");
                }
 
                INFO0("Return a Warning.");
-               return SIMIX_WARNING;
+               return;
        }
 }
 
        }
 }
 
@@ -270,7 +308,7 @@ void SIMIX_process_killall()
 /** \ingroup msg_simulation
  * \brief Clean the SIMIX simulation
  */
 /** \ingroup msg_simulation
  * \brief Clean the SIMIX simulation
  */
-SIMIX_error_t SIMIX_clean(void)
+void SIMIX_clean(void)
 {
   xbt_fifo_item_t i = NULL;
   smx_host_t h = NULL;
 {
   xbt_fifo_item_t i = NULL;
   smx_host_t h = NULL;
@@ -293,7 +331,7 @@ SIMIX_error_t SIMIX_clean(void)
   free(simix_global);
   surf_exit();
 
   free(simix_global);
   surf_exit();
 
-  return SIMIX_OK;
+  return ;
 }
 
 
 }
 
 
index b1f1b79..d700fef 100644 (file)
@@ -56,7 +56,7 @@ smx_host_t __SIMIX_host_create(const char *name,
  * This functions checks whether some data has already been associated to \a host 
    or not and attach \a data to \a host if it is possible.
  */
  * This functions checks whether some data has already been associated to \a host 
    or not and attach \a data to \a host if it is possible.
  */
-SIMIX_error_t SIMIX_host_set_data(smx_host_t host, void *data)
+void SIMIX_host_set_data(smx_host_t host, void *data)
 {
   xbt_assert0((host!=NULL), "Invalid parameters");
   xbt_assert0((host->data == NULL), "Data already set");
 {
   xbt_assert0((host!=NULL), "Invalid parameters");
   xbt_assert0((host->data == NULL), "Data already set");
@@ -64,7 +64,7 @@ SIMIX_error_t SIMIX_host_set_data(smx_host_t host, void *data)
   /* Assign data */
   host->data = data;
 
   /* Assign data */
   host->data = data;
 
-  return SIMIX_OK;
+  return ;
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
index 25c5801..08f6c8c 100644 (file)
@@ -91,7 +91,7 @@ smx_process_t SIMIX_process_create_with_arguments(const char *name,
                                     SIMIX_process_cleanup, process, 
                                     simdata->argc, simdata->argv);
 
                                     SIMIX_process_cleanup, process, 
                                     simdata->argc, simdata->argv);
 
-  simdata->last_errno=SIMIX_OK;
+  //simdata->last_errno=SIMIX_OK;
 
 
   /* Process structure */
 
 
   /* Process structure */
@@ -106,7 +106,7 @@ smx_process_t SIMIX_process_create_with_arguments(const char *name,
   xbt_context_start(process->simdata->context);
   simix_global->current_process = self;
 
   xbt_context_start(process->simdata->context);
   simix_global->current_process = self;
 
// xbt_swag_insert(process,simix_global->process_list);
+  xbt_swag_insert(process,simix_global->process_list);
   DEBUG2("Inserting %s(%s) in the to_run list",process->name,
         host->name);
   xbt_swag_insert(process,simix_global->process_to_run);
   DEBUG2("Inserting %s(%s) in the to_run list",process->name,
         host->name);
   xbt_swag_insert(process,simix_global->process_to_run);
@@ -170,7 +170,7 @@ void SIMIX_process_kill(smx_process_t process)
  * This functions checks whether \a process and \a host are valid pointers
    and change the value of the #m_host_t on which \a process is running.
  */
  * This functions checks whether \a process and \a host are valid pointers
    and change the value of the #m_host_t on which \a process is running.
  */
-SIMIX_error_t SIMIX_process_change_host(smx_process_t process, smx_host_t host)
+void SIMIX_process_change_host(smx_process_t process, smx_host_t host)
 {
   simdata_process_t simdata = NULL;
 
 {
   simdata_process_t simdata = NULL;
 
@@ -184,7 +184,7 @@ SIMIX_error_t SIMIX_process_change_host(smx_process_t process, smx_host_t host)
   simdata->host = host;
   xbt_swag_insert(process,host->simdata->process_list);
 
   simdata->host = host;
   xbt_swag_insert(process,host->simdata->process_list);
 
-  return SIMIX_OK;
+  return ;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -206,14 +206,14 @@ void *SIMIX_process_get_data(smx_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.
  */
-SIMIX_error_t SIMIX_process_set_data(smx_process_t process,void *data)
+void SIMIX_process_set_data(smx_process_t process,void *data)
 {
   xbt_assert0((process != NULL), "Invalid parameters");
   xbt_assert0((process->data == NULL), "Data already set");
   
   process->data = data;
    
 {
   xbt_assert0((process != NULL), "Invalid parameters");
   xbt_assert0((process->data == NULL), "Data already set");
   
   process->data = data;
    
-  return SIMIX_OK;
+  return ;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -227,7 +227,7 @@ smx_host_t SIMIX_process_get_host(smx_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)->host);
+  return (process->simdata->host);
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -259,28 +259,22 @@ smx_process_t SIMIX_process_self(void)
  * This functions suspend the process by suspending the task on which
  * it was waiting for the completion.
  */
  * This functions suspend the process by suspending the task on which
  * it was waiting for the completion.
  */
-SIMIX_error_t SIMIX_process_suspend(smx_process_t process)
+void SIMIX_process_suspend(smx_process_t process)
 {
   simdata_process_t simdata = NULL;
 {
   simdata_process_t simdata = NULL;
-       smx_action_t dummy;
-       char name[] = "dummy";
        
   xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
 
   if(process!=SIMIX_process_self()) {
     simdata = process->simdata;
     
        
   xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
 
   if(process!=SIMIX_process_self()) {
     simdata = process->simdata;
     
-               if ( (simdata->mutex == NULL) && (simdata->cond == NULL) ) {
-                       /* Ops, I don't know what to do yet. */
-
-               }
-               else if (simdata->mutex) {
+               if (simdata->mutex) {
                        /* process blocked on a mutex, only set suspend=1 */
                        simdata->suspended = 1;
                }
                else if (simdata->cond){
                        /* process blocked cond, suspend all actions */
                        /* process blocked on a mutex, only set suspend=1 */
                        simdata->suspended = 1;
                }
                else if (simdata->cond){
                        /* process blocked cond, suspend all actions */
-                       
+
                        /* temporaries variables */ 
                        smx_cond_t c;
                        xbt_fifo_item_t i;
                        /* temporaries variables */ 
                        smx_cond_t c;
                        xbt_fifo_item_t i;
@@ -289,25 +283,23 @@ SIMIX_error_t SIMIX_process_suspend(smx_process_t process)
                        simdata->suspended = 1;
                        c = simdata->cond;
                        xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
                        simdata->suspended = 1;
                        c = simdata->cond;
                        xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
-                                surf_workstation_resource->common_public->suspend(act->simdata->surf_action);
+                               surf_workstation_resource->common_public->suspend(act->simdata->surf_action);
                        }
                }
                        }
                }
+               else if (simdata->block_action) {
+                       simdata->suspended = 1;
+               }
                else xbt_assert0(0, "Unknown process status");
 
   }
        else {
                /* process executing, I can create an action and suspend it */
                else xbt_assert0(0, "Unknown process status");
 
   }
        else {
                /* process executing, I can create an action and suspend it */
-               dummy = SIMIX_execute(SIMIX_process_get_host(process)->simdata->host, name, 0);
-               process->simdata->block_action = dummy;
-
                process->simdata->suspended = 1;
                process->simdata->suspended = 1;
-               surf_workstation_resource->common_public->suspend(dummy->simdata->surf_action);
-               __SIMIX_wait_for_action(process,dummy);
-               SIMIX_action_destroy(dummy);
+               __SIMIX_process_block(-1);
                process->simdata->suspended = 0;
 
        }
                process->simdata->suspended = 0;
 
        }
-  return SIMIX_OK;
+  return ;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -316,7 +308,7 @@ SIMIX_error_t SIMIX_process_suspend(smx_process_t process)
  * This functions resume a suspended process by resuming the task on
  * which it was waiting for the completion.
  */
  * This functions resume a suspended process by resuming the task on
  * which it was waiting for the completion.
  */
-SIMIX_error_t SIMIX_process_resume(smx_process_t process)
+void SIMIX_process_resume(smx_process_t process)
 {
   simdata_process_t simdata = NULL;
 
 {
   simdata_process_t simdata = NULL;
 
@@ -324,34 +316,34 @@ SIMIX_error_t SIMIX_process_resume(smx_process_t process)
   CHECK_HOST();
 
   if(process == SIMIX_process_self()) {
   CHECK_HOST();
 
   if(process == SIMIX_process_self()) {
-    SIMIX_RETURN(SIMIX_OK);
+               return; 
   }
 
   simdata = process->simdata;
   }
 
   simdata = process->simdata;
-
   if(simdata->mutex) {
   if(simdata->mutex) {
+               DEBUG0("Resume process blocked on a mutex");
     simdata->suspended = 0; /* He'll wake up by itself */
     simdata->suspended = 0; /* He'll wake up by itself */
-    SIMIX_RETURN(SIMIX_OK);
+               return; 
   }
        else if (simdata->cond) {
   }
        else if (simdata->cond) {
+               DEBUG0("Resume process blocked on a conditional");
                /* temporaries variables */ 
                smx_cond_t c;
                xbt_fifo_item_t i;
                smx_action_t act;
                /* temporaries variables */ 
                smx_cond_t c;
                xbt_fifo_item_t i;
                smx_action_t act;
-
                simdata->suspended = 0;
                c = simdata->cond;
                xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
                        surf_workstation_resource->common_public->resume(act->simdata->surf_action);
                }
                simdata->suspended = 0;
                c = simdata->cond;
                xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
                        surf_workstation_resource->common_public->resume(act->simdata->surf_action);
                }
-    SIMIX_RETURN(SIMIX_OK);
+               return;
        }
        else if (simdata->block_action){
                simdata->suspended = 0;
                surf_workstation_resource->common_public->resume(simdata->block_action->simdata->surf_action);
        }
        else if (simdata->block_action){
                simdata->suspended = 0;
                surf_workstation_resource->common_public->resume(simdata->block_action->simdata->surf_action);
-    SIMIX_RETURN(SIMIX_OK);
+               return;
        }
        }
-       else xbt_assert0(0, "Unknown process status");
+       else xbt_assert0(0, "Unknown status");
 
 }
 
 
 }
 
@@ -375,15 +367,23 @@ int __SIMIX_process_block(double max_duration)
   smx_action_t dummy = NULL;
   char name[] = "dummy";
 
   smx_action_t dummy = NULL;
   char name[] = "dummy";
 
-  dummy = SIMIX_execute(SIMIX_process_get_host(process)->simdata->host, name, 0);
-       process->simdata->block_action = dummy;
+  dummy = SIMIX_execute(SIMIX_process_get_host(process), name, 0);
+       dummy->simdata->action_block=1;
+
+  /* process which will wake up when this system action finish */
+       dummy->simdata->cond_process = process; 
+
+  process->simdata->block_action = dummy;
 
   process->simdata->blocked=1;
 
   surf_workstation_resource->common_public->suspend(dummy->simdata->surf_action);
 
   process->simdata->blocked=1;
 
   surf_workstation_resource->common_public->suspend(dummy->simdata->surf_action);
-  if(max_duration>=0)
+
+  if(max_duration>=0) {
     surf_workstation_resource->common_public->set_max_duration(dummy->simdata->surf_action, 
                                                               max_duration);
     surf_workstation_resource->common_public->set_max_duration(dummy->simdata->surf_action, 
                                                               max_duration);
+               dummy->simdata->timeout_cond = process->simdata->cond;
+       }
        __SIMIX_wait_for_action(process,dummy);
        SIMIX_action_destroy(dummy);
        process->simdata->blocked=0;
        __SIMIX_wait_for_action(process,dummy);
        SIMIX_action_destroy(dummy);
        process->simdata->blocked=0;
@@ -394,58 +394,27 @@ int __SIMIX_process_block(double max_duration)
     DEBUG0("I've been resumed, let's keep going");    
   }
 
     DEBUG0("I've been resumed, let's keep going");    
   }
 
-/*
-  m_task_t dummy = SIMIX_TASK_UNINITIALIZED;
-  char blocked_name[512];
-  snprintf(blocked_name,512,"blocked [%s] (%s:%s)",
-         info, process->name, process->simdata->host->name);
-
-  XBT_IN1(": max_duration=%g",max_duration);
-
-  dummy = MSG_task_create(blocked_name, 0.0, 0, NULL);
-  
-  PAJE_PROCESS_PUSH_STATE(process,"B",NULL);
-
-  process->simdata->blocked=1;
-  __MSG_task_execute(process,dummy);
-  surf_workstation_resource->common_public->suspend(dummy->simdata->compute);
-  if(max_duration>=0)
-    surf_workstation_resource->common_public->set_max_duration(dummy->simdata->compute, 
-                                                              max_duration);
-  __MSG_wait_for_computation(process,dummy);
-  MSG_task_destroy(dummy);
-  process->simdata->blocked=0;
-
-  if(process->simdata->suspended) {
-    DEBUG0("I've been suspended in the meantime");    
-    SIMIX_process_suspend(process);
-    DEBUG0("I've been resumed, let's keep going");    
-  }
-
-  PAJE_PROCESS_POP_STATE(process);
-
-  XBT_OUT;
-  */
   return 1;
 }
 
   return 1;
 }
 
-SIMIX_error_t __SIMIX_process_unblock(smx_process_t process)
+void __SIMIX_process_unblock(smx_process_t process)
 {
   simdata_process_t simdata = NULL;
   simdata_action_t simdata_action = NULL;
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
 {
   simdata_process_t simdata = NULL;
   simdata_action_t simdata_action = NULL;
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
-  CHECK_HOST();
 
 
-       simdata = process->simdata;
+  simdata = process->simdata;
+
   if(!(simdata->block_action)) {
     xbt_assert0(0,"Process is not blocked !");
   if(!(simdata->block_action)) {
     xbt_assert0(0,"Process is not blocked !");
-    return SIMIX_WARNING;
+    return;
   }
   }
-       simdata_action = simdata->block_action->simdata;
+  
+  simdata_action = simdata->block_action->simdata;
   xbt_assert0(simdata->blocked,"Process not blocked");
   surf_workstation_resource->common_public->resume(simdata_action->surf_action);
   xbt_assert0(simdata->blocked,"Process not blocked");
   surf_workstation_resource->common_public->resume(simdata_action->surf_action);
-  SIMIX_RETURN(SIMIX_OK);
+  return ;
 
 /*
   simdata_process_t simdata = NULL;
 
 /*
   simdata_process_t simdata = NULL;
index fa4d4d9..9e067c7 100644 (file)
@@ -78,14 +78,14 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex)
        return;
 }
 
        return;
 }
 
-SIMIX_error_t SIMIX_mutex_destroy(smx_mutex_t mutex)
+void SIMIX_mutex_destroy(smx_mutex_t mutex)
 {
        if ( mutex == NULL )
 {
        if ( mutex == NULL )
-               return SIMIX_WARNING;
+               return ;
        else {
                xbt_swag_free(mutex->sleeping);
                xbt_free(mutex);
        else {
                xbt_swag_free(mutex->sleeping);
                xbt_free(mutex);
-               return SIMIX_OK;
+               return ;
        }
 }
 
        }
 }
 
@@ -131,11 +131,11 @@ void SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, double max_durat
        /* process status */    
        self->simdata->cond = cond;
 
        /* process status */    
        self->simdata->cond = cond;
 
-       xbt_swag_insert(self, cond->sleeping);
        cond->mutex = mutex;
 
        SIMIX_mutex_unlock(mutex);
        cond->mutex = mutex;
 
        SIMIX_mutex_unlock(mutex);
-       /* if the max_duration < 0, blocks forever */
+       xbt_swag_insert(self, cond->sleeping);
+       /* creates a new action to be the timeout */
        if (max_duration >=0) {
                __SIMIX_process_block(max_duration);
                self->simdata->cond = NULL;
        if (max_duration >=0) {
                __SIMIX_process_block(max_duration);
                self->simdata->cond = NULL;
@@ -146,6 +146,7 @@ void SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, double max_durat
        }
        /* get the mutex again */
        SIMIX_mutex_lock(cond->mutex);
        }
        /* get the mutex again */
        SIMIX_mutex_lock(cond->mutex);
+
        return;
 }
 
        return;
 }
 
@@ -164,19 +165,18 @@ void SIMIX_cond_broadcast(smx_cond_t cond)
        return;
 }
 
        return;
 }
 
-SIMIX_error_t SIMIX_cond_destroy(smx_cond_t cond)
+void SIMIX_cond_destroy(smx_cond_t cond)
 {
        
        if ( cond == NULL )
 {
        
        if ( cond == NULL )
-               return SIMIX_WARNING;
+               return ;
        else {
        else {
-               xbt_assert0( (xbt_swag_size(cond->sleeping) > 0)  &&
-                               (xbt_fifo_size(cond->actions) > 0), "Cannot destroy conditional");
+               xbt_assert0( xbt_swag_size(cond->sleeping) == 0 , "Cannot destroy conditional");
 
                xbt_swag_free(cond->sleeping);
                xbt_fifo_free(cond->actions);
                xbt_free(cond);
 
                xbt_swag_free(cond->sleeping);
                xbt_fifo_free(cond->actions);
                xbt_free(cond);
-               return SIMIX_OK;
+               return;
        }
 }
 
        }
 }