X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=nodestack.cc;h=b79863e2abbcc443e76721360724cc1c800d9b61;hp=47f724d856652a501805241df58e939121429e43;hb=18813c330489a982af8d745450895b0bb4479504;hpb=061b34a5d84d00df340550d75f664be5e174276c diff --git a/nodestack.cc b/nodestack.cc index 47f724d..b79863e 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -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,13 @@ Node::Node(ModelAction *act, Node *par, int nthreads) { if (act) act->set_node(this); + enabled_array=(bool *)MYMALLOC(sizeof(bool)*num_threads); + if (enabled != NULL) + memcpy(enabled_array, enabled, sizeof(bool)*num_threads); + else { + for(int i=0;i=promises.size()) - promises.resize(i+1,0); - promises[i]=1; + if (i >= promises.size()) + promises.resize(i + 1, PROMISE_IGNORE); + if (promises[i] == PROMISE_IGNORE) + promises[i] = PROMISE_UNFULFILLED; } /** @@ -72,7 +81,7 @@ void Node::set_promise(unsigned int i) { * @return true if the promise should be satisfied by the given model action. */ bool Node::get_promise(unsigned int i) { - return (i0) { + for (unsigned int i = 0; i < promises.size(); i++) { + if (promises[i] == PROMISE_UNFULFILLED) { + promises[i] = PROMISE_FULFILLED; + while (i > 0) { i--; - if (promises[i]==2) - promises[i]=1; + if (promises[i] == PROMISE_FULFILLED) + promises[i] = PROMISE_UNFULFILLED; } return true; } @@ -99,8 +108,8 @@ bool Node::increment_promise() { * @return true if we have explored all promise combinations. */ bool Node::promise_empty() { - for (unsigned int i=0;i=expiration) + return false; + if (future_index < i) { + suitableindex=i; + } + } + } - future_values.push_back(value); + if (suitableindex!=-1) { + future_values[suitableindex].expiration=expiration; + return true; + } + struct future_value newfv={value, expiration}; + future_values.push_back(newfv); return true; } @@ -123,7 +144,7 @@ bool Node::add_future_value(uint64_t value) { * @return true if the future_values set is empty. */ bool Node::future_value_empty() { - return ((future_index+1)>=future_values.size()); + return ((future_index + 1) >= future_values.size()); } /** @@ -153,7 +174,7 @@ bool Node::backtrack_empty() * @return true if the readsfrom set is empty. */ bool Node::read_from_empty() { - return ((read_from_index+1)>=may_read_from.size()); + return ((read_from_index+1) >= may_read_from.size()); } /** @@ -199,7 +220,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]; } /** @@ -218,7 +240,21 @@ void Node::add_read_from(const ModelAction *act) */ uint64_t Node::get_future_value() { ASSERT(future_indexexplore_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(), is_enabled)); total_nodes++; iter++; return NULL;