From: Brian Norris Date: Wed, 2 May 2012 07:33:10 +0000 (-0700) Subject: model: add sequence numbers to ModelAction X-Git-Tag: pldi2013~472 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3e0ad5e987371d52c9377a12cff4c4dec2b6fd81;p=model-checker.git model: add sequence numbers to ModelAction --- diff --git a/action.h b/action.h index 1bac4a4..cca5639 100644 --- 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 action_list_t; diff --git a/model.cc b/model.cc index 9117780..c3452b0 100644 --- 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 b2bcb96..ebb9211 100644 --- 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);