} else {
tid = next->get_tid();
}
- DEBUG("*** ModelChecker chose next thread = %d ***\n", tid);
+ DEBUG("*** ModelChecker chose next thread = %d ***\n", id_to_int(tid));
ASSERT(tid != THREAD_ID_T_NONE);
return thread_map->get(id_to_int(tid));
}
if (!node->set_backtrack(tid))
continue;
DEBUG("Setting backtrack: conflict = %d, instead tid = %d\n",
- prev->get_tid(), t->get_id());
+ id_to_int(prev->get_tid()),
+ id_to_int(t->get_id()));
if (DBG_ENABLED()) {
prev->print();
act->print();
/** Close out a RMWR by converting previous RMWR into a RMW or READ. */
ModelAction * ModelChecker::process_rmw(ModelAction *act) {
- int tid = id_to_int(act->get_tid());
- ModelAction *lastread = get_last_action(tid);
+ ModelAction *lastread = get_last_action(act->get_tid());
lastread->process_rmw(act);
if (act->is_rmw() && lastread->get_reads_from()!=NULL) {
mo_graph->addRMWEdge(lastread->get_reads_from(), lastread);
}
} else {
const ModelAction *prevreadfrom = act->get_reads_from();
- if (prevreadfrom != NULL && rf != prevreadfrom) {
+ //if the previous read is unresolved, keep going...
+ if (prevreadfrom == NULL)
+ continue;
+
+ if (rf != prevreadfrom) {
mo_graph->addEdge(prevreadfrom, rf);
added = true;
}
ModelAction *act = *rit;
if (act == curr) {
/*
- * If RMW, we already have all relevant edges,
- * so just skip to next thread.
- * If normal write, we need to look at earlier
- * actions, so continue processing list.
+ * 1) If RMW and it actually read from something, then we
+ * already have all relevant edges, so just skip to next
+ * thread.
+ *
+ * 2) If RMW and it didn't read from anything, we should
+ * whatever edge we can get to speed up convergence.
+ *
+ * 3) If normal write, we need to look at earlier actions, so
+ * continue processing list.
*/
- if (curr->is_rmw())
- break;
- else
+ if (curr->is_rmw()) {
+ if (curr->get_reads_from()!=NULL)
+ break;
+ else
+ continue;
+ } else
continue;
}
*/
if (act->is_write())
mo_graph->addEdge(act, curr);
- else if (act->is_read() && act->get_reads_from() != NULL)
+ else if (act->is_read()) {
+ //if previous read accessed a null, just keep going
+ if (act->get_reads_from() == NULL)
+ continue;
mo_graph->addEdge(act->get_reads_from(), curr);
+ }
added = true;
break;
} else if (act->is_read() && !act->is_synchronizing(curr) &&
ModelAction *last = get_last_action(int_to_id(i));
if (last && (rf->happens_before(last) ||
- last->get_type() == THREAD_FINISH))
+ get_thread(int_to_id(i))->is_complete()))
future_ordered = true;
for (rit = list->rbegin(); rit != list->rend(); rit++) {
ModelAction *action=*it;
if (action->is_read()) {
fprintf(file, "N%u [label=\"%u, T%u\"];\n", action->get_seq_number(),action->get_seq_number(), action->get_tid());
- fprintf(file, "N%u -> N%u[label=\"rf\", color=red];\n", action->get_seq_number(), action->get_reads_from()->get_seq_number());
+ if (action->get_reads_from()!=NULL)
+ fprintf(file, "N%u -> N%u[label=\"rf\", color=red];\n", action->get_seq_number(), action->get_reads_from()->get_seq_number());
}
if (thread_array[action->get_tid()] != NULL) {
fprintf(file, "N%u -> N%u[label=\"sb\", color=blue];\n", thread_array[action->get_tid()]->get_seq_number(), action->get_seq_number());
* @param tid The Thread's ID
* @return A Thread reference
*/
-Thread * ModelChecker::get_thread(thread_id_t tid)
+Thread * ModelChecker::get_thread(thread_id_t tid) const
{
return thread_map->get(id_to_int(tid));
}
* @param act The ModelAction
* @return A Thread reference
*/
-Thread * ModelChecker::get_thread(ModelAction *act)
+Thread * ModelChecker::get_thread(ModelAction *act) const
{
return get_thread(act->get_tid());
}
if (has_asserted())
return false;
- Thread * curr = thread_current();
+ Thread *curr = thread_current();
if (curr) {
if (curr->get_state() == THREAD_READY) {
ASSERT(priv->current_action);
ASSERT(false);
}
}
- Thread * next = scheduler->next_thread(priv->nextThread);
+ Thread *next = scheduler->next_thread(priv->nextThread);
/* Infeasible -> don't take any more steps */
if (!isfeasible())
return false;
- if (next)
- next->set_state(THREAD_RUNNING);
- DEBUG("(%d, %d)\n", curr ? curr->get_id() : -1, next ? next->get_id() : -1);
+ DEBUG("(%d, %d)\n", curr ? id_to_int(curr->get_id()) : -1,
+ next ? id_to_int(next->get_id()) : -1);
/* next == NULL -> don't take any more steps */
if (!next)
return false;
- if ( next->get_pending() != NULL ) {
- //restart a pending action
+ next->set_state(THREAD_RUNNING);
+
+ if (next->get_pending() != NULL) {
+ /* restart a pending action */
set_current_action(next->get_pending());
next->set_pending(NULL);
next->set_state(THREAD_READY);