model: add ModelChecker::get_last_seq_cst()
authorBrian Norris <banorris@uci.edu>
Fri, 13 Jul 2012 00:43:47 +0000 (17:43 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 13 Jul 2012 00:43:47 +0000 (17:43 -0700)
Add a function to get the last memory_order_seq_cst action (in the total global
sequence) performed on a particular object (i.e., memory location). Will be
used for build_reads_from_past().

model.cc
model.h

index aef7cb98f54b394cdfe1ac3ce8e2a104c6d2fe2d..8e6e1b86035e4d27243508a386edbdfe4f648f8f 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -320,6 +320,23 @@ ModelAction * ModelChecker::get_last_action(thread_id_t tid)
        return (*thrd_last_action)[id_to_int(tid)];
 }
 
+/**
+ * Gets the last memory_order_seq_cst action (in the total global sequence)
+ * performed on a particular object (i.e., memory location).
+ * @param location The object location to check
+ * @return The last seq_cst action performed
+ */
+ModelAction * ModelChecker::get_last_seq_cst(const void *location)
+{
+       action_list_t *list = &(*obj_map)[location];
+       /* Find: max({i in dom(S) | seq_cst(t_i) && isWrite(t_i) && samevar(t_i, t)}) */
+       action_list_t::reverse_iterator rit;
+       for (rit = list->rbegin(); rit != list->rend(); rit++)
+               if ((*rit)->is_write() && (*rit)->is_seqcst())
+                       return *rit;
+       return NULL;
+}
+
 ModelAction * ModelChecker::get_parent_action(thread_id_t tid)
 {
        ModelAction *parent = get_last_action(tid);
diff --git a/model.h b/model.h
index 5d74b8443543557b022b4fca51cf6cd64296c2e6..e62ff00cac3083279506d0cc0f045028235919fa 100644 (file)
--- a/model.h
+++ b/model.h
@@ -80,6 +80,7 @@ private:
        void add_action_to_lists(ModelAction *act);
        ModelAction * get_last_action(thread_id_t tid);
        ModelAction * get_parent_action(thread_id_t tid);
+       ModelAction * get_last_seq_cst(const void *location);
        void build_reads_from_past(ModelAction *curr);
 
        ModelAction *current_action;