void MC_dpor(void)
{
mc_transition_t trans = NULL;
- mc_state_t current_state = NULL;
mc_state_t next_state = NULL;
xbt_setset_cursor_t cursor = NULL;
some actions on the models. (ex. all the processes do a sleep(0) in a round). */
/* Get current state */
- current_state = (mc_state_t) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ mc_current_state = (mc_state_t) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
/* If there are transitions to execute and the maximun depth has not been reached
then perform one step of the exploration algorithm */
- if(xbt_setset_set_size(current_state->interleave) > 0 && xbt_fifo_size(mc_stack) < MAX_DEPTH){
+ if(xbt_setset_set_size(mc_current_state->interleave) > 0 && xbt_fifo_size(mc_stack) < MAX_DEPTH){
DEBUG4("Exploration detph=%d (state=%p)(%d interleave) (%d enabled)", xbt_fifo_size(mc_stack),
- current_state, xbt_setset_set_size(current_state->interleave),
- xbt_setset_set_size(current_state->enabled_transitions));
+ mc_current_state, xbt_setset_set_size(mc_current_state->interleave),
+ xbt_setset_set_size(mc_current_state->enabled_transitions));
- xbt_setset_foreach(current_state->enabled_transitions, cursor, trans){
+ xbt_setset_foreach(mc_current_state->enabled_transitions, cursor, trans){
DEBUG1("\t %s", trans->name);
}
state, and create the data structures for the new expanded state in the
exploration stack. */
MC_SET_RAW_MEM;
- trans = xbt_setset_set_extract(current_state->interleave);
+ trans = xbt_setset_set_choose(mc_current_state->interleave);
+ if(!trans->type == mc_random){
+ 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();
xbt_fifo_unshift(mc_stack, next_state);
- /* Add the transition in the done set of the current state */
- xbt_setset_set_insert(current_state->done, trans);
- trans->refcount++;
-
/* Set it as the executed transition of the current state */
- current_state->executed_transition = trans;
+ mc_current_state->executed_transition = trans;
MC_UNSET_RAW_MEM;
/* Execute the selected transition by scheduling it's associated process.
SIMIX_process_schedule(trans->process);
MC_execute_surf_actions(); /* Do surf's related black magic */
MC_schedule_enabled_processes();
+
+ if(trans->type == mc_random && trans->current_value < trans->max ){
+ trans->current_value++;
+ }else{
+ trans->current_value = trans->min;
+ xbt_setset_set_remove(mc_current_state->interleave, trans);
+ xbt_setset_set_insert(mc_current_state->done, trans);
+ }
/* Calculate the enabled transitions set of the next state:
-add the transition sets of the current state and the next state
-remove all the transitions that are disabled (mc_wait only)
-use the resulting set as the enabled transitions of the next state */
MC_SET_RAW_MEM;
- xbt_setset_add(next_state->transitions, current_state->transitions);
+ xbt_setset_add(next_state->transitions, mc_current_state->transitions);
xbt_setset_set_remove(next_state->transitions, trans);
xbt_setset_add(next_state->enabled_transitions, next_state->transitions);
xbt_setset_foreach(next_state->enabled_transitions, cursor, trans){
/* Trash the current state, no longer needed */
MC_SET_RAW_MEM;
xbt_fifo_shift(mc_stack);
- MC_state_delete(current_state);
+ MC_state_delete(mc_current_state);
/* Traverse the stack backwards until a state with a non empty interleave
set is found, deleting all the states that have it empty in the way.
(from it's predecesor state), depends on any other previous transition
executed before it. If it does then add it to the interleave set of the
state that executed that previous transition. */
- while((current_state = xbt_fifo_shift(mc_stack)) != NULL){
- q = current_state->executed_transition;
+ while((mc_current_state = xbt_fifo_shift(mc_stack)) != NULL){
+ q = mc_current_state->executed_transition;
xbt_fifo_foreach(mc_stack, item, state, mc_state_t){
if(MC_transition_depend(q, state->executed_transition)){
DEBUG3("Dependence found at state %p (%p,%p)", state, state->executed_transition, q);
break;
}
}
- if(xbt_setset_set_size(current_state->interleave) > 0){
+ if(xbt_setset_set_size(mc_current_state->interleave) > 0){
/* We found a back-tracking point, let's loop */
- xbt_fifo_unshift(mc_stack, current_state);
+ xbt_fifo_unshift(mc_stack, mc_current_state);
DEBUG1("Back-tracking to depth %d", xbt_fifo_size(mc_stack));
MC_replay(mc_stack);
MC_UNSET_RAW_MEM;
break;
}else{
- MC_state_delete(current_state);
+ MC_state_delete(mc_current_state);
}
}
}
xbt_fifo_t mc_stack = NULL;
xbt_setset_t mc_setset = NULL;
mc_stats_t mc_stats = NULL;
+mc_state_t mc_current_state = NULL;
char mc_replay_mode = FALSE;
/**
}
}
+int MC_random(int min, int max)
+{
+ MC_random_create(min,max);
+ SIMIX_process_yield();
+
+ if(!mc_replay_mode)
+ return mc_current_state->executed_transition->current_value;
+ else
+ return mc_current_state->executed_transition->current_value - 1;
+}
/**
* \brief Re-executes from the initial state all the transitions indicated by
void MC_replay(xbt_fifo_t stack)
{
xbt_fifo_item_t item;
- mc_state_t state;
mc_transition_t trans;
DEBUG0("**** Begin Replay ****");
item != xbt_fifo_get_first_item(stack);
item = xbt_fifo_get_prev_item(item)){
- state = (mc_state_t) xbt_fifo_get_item_content(item);
- trans = state->executed_transition;
+ mc_current_state = (mc_state_t) xbt_fifo_get_item_content(item);
+ trans = mc_current_state->executed_transition;
/* Update statistics */
mc_stats->visited_states++;