model: add helper for allocating new UNINIT actions
authorBrian Norris <banorris@uci.edu>
Fri, 7 Dec 2012 06:03:53 +0000 (22:03 -0800)
committerBrian Norris <banorris@uci.edu>
Fri, 7 Dec 2012 06:41:29 +0000 (22:41 -0800)
These UNINIT actions will be special; they won't enter the NodeStack,
and so they need to be snapshot-allocated. That way, they will roll-back
with the execution, instead of requiring manual deletion.

model.cc
model.h

index 3a1a7e2315128d88a0679b1a047d67593ae37906..771847ab35d0da14ba6c0b023bb54e0f31a78d19 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <algorithm>
 #include <mutex>
+#include <new>
 
 #include "model.h"
 #include "action.h"
@@ -2523,6 +2524,19 @@ bool ModelChecker::sleep_can_read_from(ModelAction * curr, const ModelAction *wr
        }
 }
 
+/**
+ * @brief Create a new action representing an uninitialized atomic
+ * @param location The memory location of the atomic object
+ * @return A pointer to a new ModelAction
+ */
+ModelAction * ModelChecker::new_uninitialized_action(void *location) const
+{
+       ModelAction *act = (ModelAction *)snapshot_malloc(sizeof(class ModelAction));
+       act = new (act) ModelAction(ATOMIC_UNINIT, std::memory_order_relaxed, location, 0, model_thread);
+       act->create_cv(NULL);
+       return act;
+}
+
 static void print_list(action_list_t *list, int exec_num = -1)
 {
        action_list_t::iterator it;
diff --git a/model.h b/model.h
index 5543eb8a0f79af705301c9201eb1b656a74b7cb6..af6802a0216612dab30b412d2955fbd1d85f25c3 100644 (file)
--- a/model.h
+++ b/model.h
@@ -187,6 +187,8 @@ private:
        bool release_seq_heads(const ModelAction *rf, rel_heads_list_t *release_heads, struct release_seq *pending) const;
        bool resolve_release_sequences(void *location, work_queue_t *work_queue);
 
+       ModelAction * new_uninitialized_action(void *location) const;
+
        ModelAction *diverge;
        ModelAction *earliest_diverge;