#define MC_is_active() _sg_do_model_check
XBT_PUBLIC(void) MC_assert(int);
-XBT_PUBLIC(int) MC_random(void);
+XBT_PUBLIC(int) MC_random(int min, int max);
XBT_PUBLIC(void) MC_automaton_new_propositional_symbol(const char* id, void* fct);
XBT_PUBLIC(void *) MC_snapshot(void);
XBT_PUBLIC(int) MC_compare_snapshots(void *s1, void *s2);
/************************** MC simcalls **********************************/
XBT_PUBLIC(void *) simcall_mc_snapshot(void);
XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
-XBT_PUBLIC(int) simcall_mc_random(void);
+XBT_PUBLIC(int) simcall_mc_random(int min, int max);
/************************** New API simcalls **********************************/
/* TUTORIAL: New API */
//xbt_abort();
}
-int SIMIX_pre_mc_random(smx_simcall_t simcall){
+int SIMIX_pre_mc_random(smx_simcall_t simcall, int min, int max){
return simcall->mc_value;
}
-int MC_random(void)
+int MC_random(int min, int max)
{
/*FIXME: return mc_current_state->executed_transition->random.value;*/
- return simcall_mc_random();
+ return simcall_mc_random(min, max);
}
/**
void MC_show_stack_safety(xbt_fifo_t stack);
void MC_dump_stack_safety(xbt_fifo_t stack);
void MC_init(void);
-int SIMIX_pre_mc_random(smx_simcall_t simcall);
+int SIMIX_pre_mc_random(smx_simcall_t simcall, int min, int max);
/********************************* Requests ***********************************/
break;
case SIMCALL_MC_RANDOM:
- if(value == 0){
- if(req->issuer->smx_host)
- label = bprintf("[(%lu)%s] MC_RANDOM (0)", req->issuer->pid, MSG_host_get_name(req->issuer->smx_host));
- else
- label = bprintf("[(%lu)] MC_RANDOM (0)", req->issuer->pid);
- }else{
- if(req->issuer->smx_host)
- label = bprintf("[(%lu)%s] MC_RANDOM (1)", req->issuer->pid, MSG_host_get_name(req->issuer->smx_host));
- else
- label = bprintf("[(%lu)] MC_RANDOM (1)", req->issuer->pid);
- }
+ if(req->issuer->smx_host)
+ label = bprintf("[(%lu)%s] MC_RANDOM (%d)", req->issuer->pid, MSG_host_get_name(req->issuer->smx_host), value);
+ else
+ label = bprintf("[(%lu)] MC_RANDOM (%d)", req->issuer->pid, value);
break;
case SIMCALL_MC_SNAPSHOT:
case SIMCALL_MC_RANDOM:
state->internal_req = *req;
- simcall_mc_random__set__result(&state->internal_req, value);
- if(value == 0){
+ if(value != simcall_mc_random__get__max(req)){
xbt_swag_foreach(process, simix_global->process_list){
procstate = &state->proc_status[process->pid];
if(process->pid == req->issuer->pid){
- procstate->state = MC_MORE_INTERLEAVE;
+ procstate->state = MC_MORE_INTERLEAVE;
break;
}
}
case SIMCALL_MC_RANDOM:
if(procstate->state == MC_INTERLEAVE)
*value = 0;
- else
- *value = 1;
+ else{
+ if(state->req_num < simcall_mc_random__get__max(&process->simcall))
+ *value = state->req_num + 1;
+ }
procstate->state = MC_DONE;
return &process->simcall;
break;
#define SIMCALL_LIST4(ACTION, sep) \
ACTION(SIMCALL_MC_SNAPSHOT, mc_snapshot, WITH_ANSWER, TPTR(result)) sep \
ACTION(SIMCALL_MC_COMPARE_SNAPSHOTS, mc_compare_snapshots, WITH_ANSWER, TINT(result), TPTR(s1), TPTR(s2)) sep \
-ACTION(SIMCALL_MC_RANDOM, mc_random, WITH_ANSWER, TINT(result)) sep
+ACTION(SIMCALL_MC_RANDOM, mc_random, WITH_ANSWER, TINT(result), TINT(min), TINT(max)) sep
#else
#define SIMCALL_LIST4(ACTION, sep)
#endif
return simcall_BODY_mc_compare_snapshots(s1, s2);
}
-int simcall_mc_random(void)
+int simcall_mc_random(int min, int max)
{
- return simcall_BODY_mc_random();
+ return simcall_BODY_mc_random(min, max);
}