X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=nodestack.cc;h=a9399edbe9a35cd28328e438a8ce6e23c8cebeb3;hp=a88166f087722c084cc9a30bf4c64ea8d0f4404e;hb=7c6c6a9bd044f8986ec17641cb8ea5f4e1aae345;hpb=35dd2c2087e76909e28e2754ad361bec5dff8f2a diff --git a/nodestack.cc b/nodestack.cc index a88166f..a9399ed 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -52,19 +52,18 @@ void Node::print() /** @brief Prints info about may_read_from set */ void Node::print_may_read_from() { - readfrom_set_t::iterator it; - for (it = may_read_from.begin(); it != may_read_from.end(); it++) - (*it)->print(); + for (unsigned int i = 0; i < may_read_from.size(); i++) + may_read_from[i]->print(); } /** * Sets a promise to explore meeting with the given node. * @param i is the promise index. */ -void Node::set_promise(uint32_t i) { - if (i>=promises.size()) - promises.resize(i+1,0); - promises[i]=1; +void Node::set_promise(unsigned int i) { + if (i >= promises.size()) + promises.resize(i + 1, PROMISE_IGNORE); + promises[i] = PROMISE_UNFULFILLED; } /** @@ -72,8 +71,8 @@ void Node::set_promise(uint32_t i) { * @param i The promise index. * @return true if the promise should be satisfied by the given model action. */ -bool Node::get_promise(uint32_t 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; } @@ -100,8 +99,8 @@ bool Node::increment_promise() { * @return true if we have explored all promise combinations. */ bool Node::promise_empty() { - for (unsigned int i=0;i=future_values.size()); + return ((future_index + 1) >= future_values.size()); } - /** * Checks if the Thread associated with this thread ID has been explored from * this Node already. @@ -150,17 +148,14 @@ bool Node::backtrack_empty() return (numBacktracks == 0); } - /** * Checks whether the readsfrom set for this node is 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()); } - - /** * Mark the appropriate backtracking information for exploring a thread choice. * @param act The ModelAction to explore @@ -221,19 +216,26 @@ void Node::add_read_from(const ModelAction *act) * where this->action is a 'read'. * @return The first element in future_values */ - uint64_t Node::get_future_value() { ASSERT(future_indexaction is a 'read'. * @return The first element in may_read_from */ const ModelAction * Node::get_read_from() { - if (read_from_index