Merge branch 'master' into mutex
authorBrian Demsky <bdemsky@uci.edu>
Tue, 18 Sep 2012 05:18:56 +0000 (22:18 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Tue, 18 Sep 2012 05:18:56 +0000 (22:18 -0700)
Makefile
action.h
model.cc
nodestack.cc
nodestack.h

index 53b0331f2a250f7a18af120f87929b4cee605fdd..a732cb763ad7a8dcf1ef9900ac4473921000163c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ include common.mk
 OBJECTS = libthreads.o schedule.o model.o threads.o librace.o action.o \
          nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
          datarace.o impatomic.o cmodelint.o \
-         snapshot.o malloc.o mymemory.o common.o
+         snapshot.o malloc.o mymemory.o common.o mutex.o
 
 CPPFLAGS += -Iinclude -I. -rdynamic
 LDFLAGS = -ldl -lrt
index 9fa7a91c3f93443714f54ec34b153c4d09a1c20b..0e3f3d572792303444c2e4efa3cce73326135039 100644 (file)
--- a/action.h
+++ b/action.h
@@ -40,7 +40,10 @@ typedef enum action_type {
        ATOMIC_RMWC,          /**< Convert an atomic RMW action into a READ */
        ATOMIC_INIT,          /**< Initialization of an atomic object (e.g.,
                               *   atomic_init()) */
-       ATOMIC_FENCE
+       ATOMIC_FENCE,
+       ATOMIC_LOCK,
+       ATOMIC_TRYLOCK,
+       ATOMIC_UNLOCK
 } action_type_t;
 
 /* Forward declaration */
index 954c07dd6dacdfc9473a4aa3f5e0a2f8db38bcbf..ede3797b7f4933f1c16f0a054d8b558ef63baff1 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -358,7 +358,7 @@ Thread * ModelChecker::check_current_action(ModelAction *curr)
                curr = tmp;
                compute_promises(curr);
        } else {
-               ModelAction *tmp = node_stack->explore_action(curr);
+               ModelAction *tmp = node_stack->explore_action(curr, NULL);
                if (tmp) {
                        /* Discard duplicate ModelAction; use action from NodeStack */
                        /* First restore type and order in case of RMW operation */
index 431baafbdce9809a2cb49ebcea30837182c852cf..69f0b5f513640f5861c6c3bf117c73fc440c7da6 100644 (file)
@@ -17,7 +17,7 @@
  * @param nthreads The number of threads which exist at this point in the
  * execution trace.
  */
-Node::Node(ModelAction *act, Node *par, int nthreads)
+Node::Node(ModelAction *act, Node *par, int nthreads, bool *enabled)
        : action(act),
        parent(par),
        num_threads(nthreads),
@@ -31,6 +31,12 @@ Node::Node(ModelAction *act, Node *par, int nthreads)
 {
        if (act)
                act->set_node(this);
+       enabled_array=(bool *)MYMALLOC(sizeof(bool)*num_threads);
+       if (enabled)
+               memcpy(enabled_array, enabled, sizeof(bool)*num_threads);
+       else 
+               for(int i=0;i<num_threads;i++)
+                       enabled_array[i]=false;
 }
 
 /** @brief Node desctructor */
@@ -38,6 +44,7 @@ Node::~Node()
 {
        if (action)
                delete action;
+       MYFREE(enabled_array);
 }
 
 /** Prints debugging info for the ModelAction associated with this Node */
@@ -212,7 +219,8 @@ thread_id_t Node::get_next_backtrack()
 
 bool Node::is_enabled(Thread *t)
 {
-       return id_to_int(t->get_id()) < num_threads;
+       int thread_id=id_to_int(t->get_id());
+       return thread_id < num_threads && enabled_array[thread_id];
 }
 
 /**
@@ -324,7 +332,7 @@ void NodeStack::print()
        printf("............................................\n");
 }
 
-ModelAction * NodeStack::explore_action(ModelAction *act)
+ModelAction * NodeStack::explore_action(ModelAction *act, bool * enabled)
 {
        DBG();
 
@@ -339,7 +347,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act)
 
        /* Record action */
        get_head()->explore_child(act);
-       node_list.push_back(new Node(act, get_head(), model->get_num_threads()));
+       node_list.push_back(new Node(act, get_head(), model->get_num_threads(), enabled));
        total_nodes++;
        iter++;
        return NULL;
index 6c9779497e71f96e0621b37e762fbb199bd0556c..6cd8cfd30806c7463d6710e5251041bf4b64cd81 100644 (file)
@@ -44,7 +44,7 @@ struct future_value {
  */
 class Node {
 public:
-       Node(ModelAction *act = NULL, Node *par = NULL, int nthreads = 1);
+       Node(ModelAction *act = NULL, Node *par = NULL, int nthreads = 1, bool *enabled_array = NULL);
        ~Node();
        /* return true = thread choice has already been explored */
        bool has_been_explored(thread_id_t tid);
@@ -93,6 +93,7 @@ private:
        std::vector< bool, MyAlloc<bool> > explored_children;
        std::vector< bool, MyAlloc<bool> > backtrack;
        int numBacktracks;
+       bool *enabled_array;
 
        /** The set of ModelActions that this the action at this Node may read
         *  from. Only meaningful if this Node represents a 'read' action. */
@@ -119,7 +120,7 @@ class NodeStack {
 public:
        NodeStack();
        ~NodeStack();
-       ModelAction * explore_action(ModelAction *act);
+       ModelAction * explore_action(ModelAction *act, bool * enabled);
        Node * get_head();
        Node * get_next();
        void reset_execution();