model: add "bad synchronization" flag
authorBrian Norris <banorris@uci.edu>
Mon, 1 Oct 2012 20:29:00 +0000 (13:29 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 1 Oct 2012 20:29:00 +0000 (13:29 -0700)
Can be used for aborting a trace when an incorrectly-ordered
synchronization occurs.

model.cc
model.h

index 1711e1a002b6d105cb413efec6c20e644f51f0f8..9d2dbb61ef577c43421f6ab071fe5fc7c9323004 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -38,7 +38,8 @@ ModelChecker::ModelChecker(struct model_params params) :
        mo_graph(new CycleGraph()),
        failed_promise(false),
        too_many_reads(false),
        mo_graph(new CycleGraph()),
        failed_promise(false),
        too_many_reads(false),
-       asserted(false)
+       asserted(false),
+       bad_synchronization(false)
 {
        /* Allocate this "size" on the snapshotting heap */
        priv = (struct model_snapshot_members *)calloc(1, sizeof(*priv));
 {
        /* Allocate this "size" on the snapshotting heap */
        priv = (struct model_snapshot_members *)calloc(1, sizeof(*priv));
@@ -80,6 +81,7 @@ void ModelChecker::reset_to_initial_state()
        node_stack->reset_execution();
        failed_promise = false;
        too_many_reads = false;
        node_stack->reset_execution();
        failed_promise = false;
        too_many_reads = false;
+       bad_synchronization = false;
        reset_asserted();
        snapshotObject->backTrackBeforeStep(0);
 }
        reset_asserted();
        snapshotObject->backTrackBeforeStep(0);
 }
@@ -740,10 +742,12 @@ bool ModelChecker::isfeasibleotherthanRMW() {
                        DEBUG("Infeasible: failed promise\n");
                if (too_many_reads)
                        DEBUG("Infeasible: too many reads\n");
                        DEBUG("Infeasible: failed promise\n");
                if (too_many_reads)
                        DEBUG("Infeasible: too many reads\n");
+               if (bad_synchronization)
+                       DEBUG("Infeasible: bad synchronization ordering\n");
                if (promises_expired())
                        DEBUG("Infeasible: promises expired\n");
        }
                if (promises_expired())
                        DEBUG("Infeasible: promises expired\n");
        }
-       return !mo_graph->checkForCycles() && !failed_promise && !too_many_reads && !promises_expired();
+       return !mo_graph->checkForCycles() && !failed_promise && !too_many_reads && !bad_synchronization && !promises_expired();
 }
 
 /** Returns whether the current completed trace is feasible. */
 }
 
 /** Returns whether the current completed trace is feasible. */
diff --git a/model.h b/model.h
index 4a1fcf49e2b64e732d52865bc0dc921031a61bf9..4b9e3ff53f0082b30efd095b5618186480882d5e 100644 (file)
--- a/model.h
+++ b/model.h
@@ -91,6 +91,11 @@ public:
        void finish_execution();
        bool isfeasibleprefix();
        void set_assert() {asserted=true;}
        void finish_execution();
        bool isfeasibleprefix();
        void set_assert() {asserted=true;}
+
+       /** @brief Alert the model-checker that an incorrectly-ordered
+        * synchronization was made */
+       void set_bad_synchronization() { bad_synchronization = true; }
+
        const model_params params;
 
        MEMALLOC
        const model_params params;
 
        MEMALLOC
@@ -196,6 +201,8 @@ private:
        bool failed_promise;
        bool too_many_reads;
        bool asserted;
        bool failed_promise;
        bool too_many_reads;
        bool asserted;
+       /** @brief Incorrectly-ordered synchronization was made */
+       bool bad_synchronization;
 };
 
 extern ModelChecker *model;
 };
 
 extern ModelChecker *model;