X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=nodestack.cc;h=a9399edbe9a35cd28328e438a8ce6e23c8cebeb3;hb=2cd14a2ba5f68a5bd35c1094c9d5a83891b483f8;hp=77e24398931a0a2ee3d9e7bb662813ae4f3f7231;hpb=8dcdd425a04e56cb0a41b6fff18c044118ffed62;p=model-checker.git diff --git a/nodestack.cc b/nodestack.cc index 77e2439..a9399ed 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -52,46 +52,41 @@ 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(); } -/** This method sets a promise to explore meeting with the given - * node. - * @param i is the promise index. +/** + * 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; } -/** This method looks up whether a given promise should be satisfied - * by this node. - * - * @param i is the promise index. +/** + * Looks up whether a given promise should be satisfied by this node. + * @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; } @@ -99,14 +94,13 @@ bool Node::increment_promise() { return false; } -/** This method returns whether the promise set is empty. - * - * @return true if we have explored all promise combinations. +/** + * Returns whether the promise set is empty. + * @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. @@ -157,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 @@ -228,21 +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'. - * @todo Perform reads_from backtracking/replay properly, so that this function - * may remove elements from may_read_from * @return The first element in may_read_from */ const ModelAction * Node::get_read_from() { - if (read_from_index