model: add sequence numbers to ModelAction
authorBrian Norris <banorris@uci.edu>
Wed, 2 May 2012 07:33:10 +0000 (00:33 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 2 May 2012 23:06:16 +0000 (16:06 -0700)
action.h
model.cc
model.h

index 1bac4a4553fe32125633ed91e09b6e0705ea52b4..cca56390567a0b66b265d371656417b60a34e748 100644 (file)
--- a/action.h
+++ b/action.h
@@ -28,6 +28,7 @@ public:
        action_type get_type() { return type; }
        memory_order get_mo() { return order; }
        void * get_location() { return location; }
+       int get_seq_number() { return seq_number; }
 
        TreeNode * get_node() { return node; }
        void set_node(TreeNode *n) { node = n; }
@@ -46,6 +47,7 @@ private:
        thread_id_t tid;
        int value;
        TreeNode *node;
+       int seq_number;
 };
 
 typedef std::list<class ModelAction *> action_list_t;
index 91177806ce7638f93a1456b76a1167d1d12c6d93..c3452b07e5e7c502384ddfd2c8a0c981be2bf620 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -14,6 +14,7 @@ ModelChecker::ModelChecker()
 {
        /* First thread created will have id (INITIAL_THREAD_ID + 1) */
        this->used_thread_id = INITIAL_THREAD_ID;
+       used_sequence_numbers = 0;
        /* Initialize default scheduler */
        this->scheduler = new Scheduler();
 
@@ -45,6 +46,7 @@ void ModelChecker::reset_to_initial_state()
        currentNode = rootNode;
        current_action = NULL;
        used_thread_id = INITIAL_THREAD_ID;
+       used_sequence_numbers = 0;
        /* scheduler reset ? */
 }
 
@@ -53,6 +55,11 @@ thread_id_t ModelChecker::get_next_id()
        return ++used_thread_id;
 }
 
+int ModelChecker::get_next_seq_num()
+{
+       return ++used_sequence_numbers;
+}
+
 Thread * ModelChecker::schedule_next_thread()
 {
        Thread *t;
@@ -250,6 +257,7 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int
        act->location = loc;
        act->tid = t->get_id();
        act->value = value;
+       act->seq_number = model->get_next_seq_num();
 }
 
 bool ModelAction::is_read()
@@ -331,6 +339,6 @@ void ModelAction::print(void)
                type_str = "unknown type";
        }
 
-       printf("Thread: %d\tAction: %s\tMO: %d\tLoc: %14p\tValue: %d\n",
-                       id_to_int(tid), type_str, order, location, value);
+       printf("(%4d) Thread: %d\tAction: %s\tMO: %d\tLoc: %14p\tValue: %d\n",
+                       seq_number, id_to_int(tid), type_str, order, location, value);
 }
diff --git a/model.h b/model.h
index b2bcb96f54a79513a6eb7c7890c796a4203f0299..ebb9211fb227c28e27ba075af04e14f34e9aaf59 100644 (file)
--- a/model.h
+++ b/model.h
@@ -54,12 +54,14 @@ public:
        Thread * get_thread(thread_id_t tid) { return thread_map[id_to_int(tid)]; }
 
        thread_id_t get_next_id();
+       int get_next_seq_num();
 
        int switch_to_master(ModelAction *act);
 
        bool next_execution();
 private:
        int used_thread_id;
+       int used_sequence_numbers;
        int num_executions;
 
        ModelAction * get_last_conflict(ModelAction *act);