Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean up actions when a condition is destroyed.
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 4 Aug 2007 21:29:56 +0000 (21:29 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 4 Aug 2007 21:29:56 +0000 (21:29 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3950 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/simix/simix.h
src/simix/smx_process.c
src/simix/smx_synchro.c

index 93cc3b7..bb011dc 100644 (file)
@@ -119,6 +119,7 @@ XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond,smx_mutex_t mutex, doub
 XBT_PUBLIC(void) SIMIX_cond_broadcast(smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_cond_destroy(smx_cond_t cond);
 XBT_PUBLIC(void) SIMIX_register_condition_to_action(smx_action_t action, smx_cond_t cond);
+XBT_PUBLIC(void) SIMIX_unregister_condition_to_action(smx_action_t action, smx_cond_t cond);
 XBT_PUBLIC(xbt_fifo_t) SIMIX_cond_get_actions(smx_cond_t cond);
 
 
index c41798c..8577616 100644 (file)
@@ -169,20 +169,28 @@ void SIMIX_process_kill(smx_process_t process)
    DEBUG2("Killing process %s on %s",process->name, p_simdata->s_host->name);
   
    /* Cleanup if we were waiting for something */
+   DEBUG0("Here!");
    if (p_simdata->mutex) 
       xbt_swag_remove(process,p_simdata->mutex->sleeping);
    
+   DEBUG0("Here!");
    if (p_simdata->cond) 
       xbt_swag_remove(process,p_simdata->cond->sleeping);
 
+   DEBUG0("Here!");
    xbt_swag_remove(process, simix_global->process_to_run);
+   DEBUG0("Here!");
    xbt_swag_remove(process, simix_global->process_list);
+   DEBUG2("%p here! killing %p",simix_global->current_process,process);
    xbt_context_kill(process->simdata->context);
 
+   DEBUG0("Here!");
    if(process==SIMIX_process_self()) {
       /* I just killed myself */
+     DEBUG0("Here!");
       xbt_context_yield();
    }
+   DEBUG0("Here!");
 }
 
 /**
index aec653b..b80c933 100644 (file)
@@ -300,8 +300,15 @@ void SIMIX_cond_destroy(smx_cond_t cond)
        if ( cond == NULL )
                return ;
        else {
+         xbt_fifo_item_t item = NULL;
+         smx_action_t action = NULL;
+
                xbt_assert0( xbt_swag_size(cond->sleeping) == 0 , "Cannot destroy conditional since someone is still using it");
                xbt_swag_free(cond->sleeping);
+
+               xbt_fifo_foreach(cond->actions,item,action,smx_action_t) {
+                 SIMIX_unregister_condition_to_action(action, cond);
+               }
                xbt_fifo_free(cond->actions);
                xbt_free(cond);
                return;
@@ -323,4 +330,19 @@ void SIMIX_register_condition_to_action(smx_action_t action, smx_cond_t cond)
        xbt_fifo_push(action->cond_list,cond);
 }
 
+/**
+ *     \brief Unset a condition to an action
+ *
+ *     Destroys the "link" between an action and a condition. 
+ *     \param action SIMIX action
+ *     \param cond SIMIX cond
+ */
+void SIMIX_unregister_condition_to_action(smx_action_t action, smx_cond_t cond)
+{
+       xbt_assert0( (action != NULL) && (cond != NULL), "Invalid parameters");
+
+       while(xbt_fifo_remove(action->cond_list,cond)) {}
+}
+
+