model: add special model-checker Thread to ModelChecker
authorBrian Norris <banorris@uci.edu>
Sat, 6 Oct 2012 02:18:13 +0000 (19:18 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 05:22:52 +0000 (22:22 -0700)
Note the change in take_step(), so that we base the "current thread" off
of the provided ModelAction, rather than thread_current() (i.e., the
Scheduler). This is because the Scheduler will never run the
model-checker thread.

model.cc
model.h

index c5e41ab74c4be12cc8605860548abee71192a532..c1818ad5bfb8fb48c8b8e9221212119b2ca125ff 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -47,6 +47,10 @@ ModelChecker::ModelChecker(struct model_params params) :
        priv = (struct model_snapshot_members *)calloc(1, sizeof(*priv));
        /* First thread created will have id INITIAL_THREAD_ID */
        priv->next_thread_id = INITIAL_THREAD_ID;
+
+       /* Initialize a model-checker thread, for special ModelActions */
+       model_thread = new Thread(get_next_id());
+       thread_map->put(id_to_int(model_thread->get_id()), model_thread);
 }
 
 /** @brief Destructor */
@@ -1944,7 +1948,7 @@ bool ModelChecker::take_step() {
        if (has_asserted())
                return false;
 
-       Thread *curr = thread_current();
+       Thread *curr = priv->current_action ? get_thread(priv->current_action) : NULL;
        if (curr) {
                if (curr->get_state() == THREAD_READY) {
                        ASSERT(priv->current_action);
diff --git a/model.h b/model.h
index 4032ef1263782f72b55d4841d37a9f9e5fd45e62..68831b867885fe83a7765e2716c8d07cc67f9726 100644 (file)
--- a/model.h
+++ b/model.h
@@ -203,6 +203,10 @@ private:
         * together for efficiency and maintainability. */
        struct model_snapshot_members *priv;
 
+       /** A special model-checker Thread; used for associating with
+        *  model-checker-related ModelAcitons */
+       Thread *model_thread;
+
        /**
         * @brief The modification order graph
         *