From: Brian Demsky Date: Fri, 19 Apr 2013 00:34:41 +0000 (-0700) Subject: Remove special cases for printing SC executions. X-Git-Tag: oopsla2013~35 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=5566833b04fb088b315dcde5148e05a9ea80c2df Remove special cases for printing SC executions. Just use happens before relation instead. Also include a criteria to keep things in execution order as much as possible. --- diff --git a/scanalysis.cc b/scanalysis.cc index daf41f8..abed220 100644 --- a/scanalysis.cc +++ b/scanalysis.cc @@ -51,13 +51,14 @@ bool SCAnalysis::merge(ClockVector *cv, const ModelAction *act, ClockVector *cv2 ModelAction * SCAnalysis::getNextAction() { ModelAction *act = NULL; + /* Find the earliest in SC ordering */ for (int i = 0; i <= maxthreads; i++) { action_list_t *threadlist = &threadlists[i]; if (threadlist->empty()) continue; ModelAction *first = threadlist->front(); - if (act == NULL) { - act = first; + if (act==NULL) { + act=first; continue; } ClockVector *cv = cvmap.get(act); @@ -67,29 +68,35 @@ ModelAction * SCAnalysis::getNextAction() { } if (act == NULL) return act; - //print cycles in a nice way to avoid confusion - //make sure thread starts appear after the create - if (act->is_thread_start()) { - ModelAction *createact = execution->get_thread(act)->get_creation(); - if (createact) { - action_list_t *threadlist = &threadlists[id_to_int(createact->get_tid())]; - if (!threadlist->empty()) { - ModelAction *first = threadlist->front(); - if (first->get_seq_number() <= createact->get_seq_number()) - act = first; - } + + + /* Find the model action with the earliest sequence number in case of a cycle. + */ + + for (int i = 0; i <= maxthreads; i++) { + action_list_t *threadlist = &threadlists[i]; + if (threadlist->empty()) + continue; + ModelAction *first = threadlist->front(); + ClockVector *cv = cvmap.get(act); + ClockVector *cvfirst = cvmap.get(first); + if (first->get_seq_number()get_seq_number()&& + (cv->synchronized_since(first)||!cvfirst->synchronized_since(act))) { + act=first; } } - //make sure that joins appear after the thread is finished - if (act->is_thread_join()) { - int jointhread = id_to_int(act->get_thread_operand()->get_id()); - action_list_t *threadlist = &threadlists[jointhread]; - if (!threadlist->empty()) { - act = threadlist->front(); + /* See if hb demands an earlier action. */ + for (int i = 0; i <= maxthreads; i++) { + action_list_t *threadlist = &threadlists[i]; + if (threadlist->empty()) + continue; + ModelAction *first = threadlist->front(); + ClockVector *cv = act->get_cv(); + if (cv->synchronized_since(first)) { + act = first; } } - return act; }