fix some of the bugs related to barrier example...
authorBrian Demsky <bdemsky@uci.edu>
Wed, 10 Oct 2012 00:54:43 +0000 (17:54 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Wed, 10 Oct 2012 00:54:43 +0000 (17:54 -0700)
action.cc
action.h
main.cc
model.cc
model.h

index 5e050810e7526408828b27c74cad76fcdef95a4b..1a819eaf5584f1e97e88fca439104392c07b7f1b 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -111,6 +111,11 @@ bool ModelAction::is_write() const
        return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT;
 }
 
+bool ModelAction::could_be_write() const
+{
+       return is_write() || is_rmwr();
+}
+
 bool ModelAction::is_rmwr() const
 {
        return type == ATOMIC_RMWR;
@@ -217,11 +222,11 @@ bool ModelAction::could_synchronize_with(const ModelAction *act) const
 
        // Explore interleavings of seqcst writes to guarantee total order
        // of seq_cst operations that don't commute
-       if ((is_write() || act->is_write()) && is_seqcst() && act->is_seqcst())
+       if ((could_be_write() || act->could_be_write()) && is_seqcst() && act->is_seqcst())
                return true;
 
        // Explore synchronizing read/write pairs
-       if (is_read() && is_acquire() && act->is_write() && act->is_release())
+       if (is_read() && is_acquire() && act->could_be_write() && act->is_release())
                return true;
 
        // Otherwise handle by reads_from relation
index 496093134ec7b6c96437c6ffa6f060e87894bdd9..4f63c181b0a3f2fca0a798fead208029af4a364b 100644 (file)
--- a/action.h
+++ b/action.h
@@ -94,6 +94,7 @@ public:
        bool is_failed_trylock() const;
        bool is_read() const;
        bool is_write() const;
+       bool could_be_write() const;
        bool is_rmwr() const;
        bool is_rmwc() const;
        bool is_rmw() const;
diff --git a/main.cc b/main.cc
index 6624f0685e42c551949273feb3af9d2e0a67597a..fc1b2779daa657ae6460293da49d29a5c95ec21d 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -19,6 +19,7 @@ static void param_defaults(struct model_params * params) {
        params->maxfuturedelay = 100;
        params->fairwindow = 0;
        params->enabledcount = 1;
+       params->bound = 0;
 }
 
 static void print_usage(struct model_params *params) {
@@ -36,13 +37,14 @@ static void print_usage(struct model_params *params) {
 "                      enabled sufficiently many times should receive\n"
 "                      priority for execution. Default: %d\n"
 "-e                    Enabled count. Default: %d\n"
+"-b                    Upper length bound. Default: %d\n"
 "--                    Program arguments follow.\n\n",
-params->maxreads, params->maxfuturedelay, params->fairwindow, params->enabledcount);
+params->maxreads, params->maxfuturedelay, params->fairwindow, params->enabledcount, params->bound);
        exit(EXIT_SUCCESS);
 }
 
 static void parse_options(struct model_params *params, int *argc, char ***argv) {
-       const char *shortopts = "hm:s:f:e:";
+       const char *shortopts = "hm:s:f:e:b:";
        int opt;
        bool error = false;
        while (!error && (opt = getopt(*argc, *argv, shortopts)) != -1) {
@@ -59,6 +61,9 @@ static void parse_options(struct model_params *params, int *argc, char ***argv)
                case 'e':
                        params->enabledcount = atoi(optarg);
                        break;
+               case 'b':
+                       params->bound = atoi(optarg);
+                       break;
                case 'm':
                        params->maxreads = atoi(optarg);
                        break;
index 5753c5c4e016e2a6b7433aeee60706e777505860..c0cc93eb0a80523eefc48f2fe7ec3c8119d8619c 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -260,7 +260,8 @@ bool ModelChecker::next_execution()
        DEBUG("Number of acquires waiting on pending release sequences: %zu\n",
                        pending_rel_seqs->size());
 
-       if (isfinalfeasible() || DBG_ENABLED())
+
+       if (isfinalfeasible() || (params.bound != 0 && priv->used_sequence_numbers > params.bound ) || DBG_ENABLED() )
                print_summary();
 
        if ((diverge = get_next_backtrack()) == NULL)
@@ -1873,7 +1874,7 @@ void ModelChecker::build_reads_from_past(ModelAction *curr)
                                        curr->print();
                                }
 
-                               if (curr->get_sleep_flag()) {
+                               if (curr->get_sleep_flag() && ! curr->is_seqcst()) {
                                        if (sleep_can_read_from(curr, act))
                                                curr->get_node()->add_read_from(act);
                                } else
@@ -2073,6 +2074,12 @@ bool ModelChecker::take_step() {
        if (!isfeasible())
                return false;
 
+       if (params.bound != 0) {
+               if (priv->used_sequence_numbers > params.bound) {
+                       return false;
+               }
+       }
+
        DEBUG("(%d, %d)\n", curr ? id_to_int(curr->get_id()) : -1,
                        next ? id_to_int(next->get_id()) : -1);
 
diff --git a/model.h b/model.h
index 6e470c0eaa66a9b126d3f223080bf9114d7d1afc..01dd35b03752504dc9416543f38588018297adf6 100644 (file)
--- a/model.h
+++ b/model.h
@@ -36,6 +36,7 @@ struct model_params {
        int maxfuturedelay;
        unsigned int fairwindow;
        unsigned int enabledcount;
+       unsigned int bound;
 };
 
 struct PendingFutureValue {