xbt_setset_set_insert(initial_state->interleave, trans);
MC_UNSET_RAW_MEM;
- trans->refcount++;
-
/* Update Statistics */
mc_stats->state_size += xbt_setset_set_size(initial_state->enabled_transitions);
}
xbt_setset_set_remove(mc_current_state->interleave, trans);
/* Add the transition in the done set of the current state */
xbt_setset_set_insert(mc_current_state->done, trans);
- trans->refcount++;
}
next_state = MC_state_new();
void MC_dump_stack(xbt_fifo_t stack)
{
mc_state_t state;
- mc_transition_t trans;
+ MC_show_stack(stack);
+
MC_SET_RAW_MEM;
- while( (state = (mc_state_t)xbt_fifo_pop(stack)) != NULL ){
- trans = state->executed_transition;
- if(trans)
- INFO1("%s", trans->name);
-
+ while( (state = (mc_state_t)xbt_fifo_pop(stack)) != NULL )
MC_state_delete(state);
- }
MC_UNSET_RAW_MEM;
}
mc_transition_t trans;
xbt_fifo_item_t item;
- INFO0("===========================");
for(item=xbt_fifo_get_last_item(stack);
- (item?(state=(mc_state_t)(xbt_fifo_get_item_content(item))):(NULL)); \
+ (item?(state=(mc_state_t)(xbt_fifo_get_item_content(item))):(NULL));
item=xbt_fifo_get_prev_item(item)){
trans = state->executed_transition;
if(trans){
}
}
-
/**
* \brief Schedules all the process that are ready to run
* As a side effect it performs some clean-up required by SIMIX
mc_state_t state = NULL;
state = xbt_new0(s_mc_state_t, 1);
+ state->created_transitions = xbt_setset_new_set(mc_setset);
state->transitions = xbt_setset_new_set(mc_setset);
state->enabled_transitions = xbt_setset_new_set(mc_setset);
state->interleave = xbt_setset_new_set(mc_setset);
*/
void MC_state_delete(mc_state_t state)
{
- /*if(state->executed_transition)
- MC_transition_delete(state->executed_transition);*/
+ xbt_setset_cursor_t cursor;
+ mc_transition_t trans;
+
+ xbt_setset_foreach(state->created_transitions, cursor, trans){
+ MC_transition_delete(trans);
+ }
+
xbt_setset_destroy_set(state->transitions);
xbt_setset_destroy_set(state->enabled_transitions);
xbt_setset_destroy_set(state->interleave);
if(!mc_replay_mode){
MC_SET_RAW_MEM;
mc_transition_t trans = xbt_new0(s_mc_transition_t, 1);
- trans->refcount = 1;
/* Generate a string for the "type" */
switch(type){
trans->rdv = rdv;
trans->comm = comm;
/* Push it onto the enabled transitions set of the current state */
- current_state = (mc_state_t)
+
+ current_state = (mc_state_t)
xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
return trans;
trans->name = bprintf("[%s][%s] mc_random(%d,%d) (%p)", p->smx_host->name, p->name, min, max, trans);
xbt_free(type_str);
- trans->refcount = 1;
trans->type = mc_random ;
trans->process = p;
trans->min = min;
/* Push it onto the enabled transitions set of the current state */
current_state = (mc_state_t)
xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
}
*/
void MC_transition_delete(mc_transition_t trans)
{
- /* Only delete it if there are no references, otherwise decrement refcount */
- if(--trans->refcount == 0){
- xbt_free(trans->name);
- xbt_free(trans);
- }
+ xbt_free(trans->name);
+ xbt_free(trans);
}
/**
typedef struct s_mc_transition{
XBT_SETSET_HEADERS;
char* name;
- unsigned int refcount;
mc_trans_type_t type;
smx_process_t process;
smx_rdv_t rdv;
/******************************** States **************************************/
typedef struct mc_state{
- xbt_setset_set_t transitions;
- xbt_setset_set_t enabled_transitions;
- xbt_setset_set_t interleave;
- xbt_setset_set_t done;
- mc_transition_t executed_transition;
+ xbt_setset_set_t created_transitions; /* created in this state */
+ xbt_setset_set_t transitions; /* created in this state + inherited */
+ xbt_setset_set_t enabled_transitions; /* they can be executed by the mc */
+ xbt_setset_set_t interleave; /* the ones to be executed by the mc */
+ xbt_setset_set_t done; /* already executed transitions */
+ mc_transition_t executed_transition; /* last executed transition */
} s_mc_state_t, *mc_state_t;
extern xbt_fifo_t mc_stack;