X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=nodestack.cc;h=088fad8904b473aa603b457b188e6c9644cdd248;hb=ecba3e5519898cbf612e7d4e2eaef63d1d8af7d3;hp=11b83cc1b341145c1ed1faf130afa4bf9ae28d8b;hpb=e9e73da450a5045d569a947072bb20232cede7f4;p=model-checker.git diff --git a/nodestack.cc b/nodestack.cc index 11b83cc..088fad8 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -41,13 +41,13 @@ Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness) ASSERT(act); act->set_node(this); int currtid = id_to_int(act->get_tid()); - int prevtid = (prevfairness != NULL) ? id_to_int(prevfairness->action->get_tid()) : 0; + int prevtid = prevfairness ? id_to_int(prevfairness->action->get_tid()) : 0; if (model->params.fairwindow != 0) { - for (int i = 0; i < nthreads; i++) { + for (int i = 0; i < num_threads; i++) { ASSERT(i < ((int)fairness.size())); struct fairness_info *fi = &fairness[i]; - struct fairness_info *prevfi = (par != NULL) && (i < par->get_num_threads()) ? &par->fairness[i] : NULL; + struct fairness_info *prevfi = (parent && i < parent->get_num_threads()) ? &parent->fairness[i] : NULL; if (prevfi) { *fi = *prevfi; } @@ -108,7 +108,8 @@ void Node::print_may_read_from() * Sets a promise to explore meeting with the given node. * @param i is the promise index. */ -void Node::set_promise(unsigned int i, bool is_rmw) { +void Node::set_promise(unsigned int i, bool is_rmw) +{ if (i >= promises.size()) promises.resize(i + 1, PROMISE_IGNORE); if (promises[i] == PROMISE_IGNORE) { @@ -132,7 +133,8 @@ bool Node::get_promise(unsigned int i) const * Increments to the next combination of promises. * @return true if we have a valid combination. */ -bool Node::increment_promise() { +bool Node::increment_promise() +{ DBG(); unsigned int rmw_count = 0; for (unsigned int i = 0; i < promises.size(); i++) { @@ -189,7 +191,8 @@ int Node::get_misc() const return misc_index; } -bool Node::increment_misc() { +bool Node::increment_misc() +{ return (misc_index < misc_max) && ((++misc_index) < misc_max); } @@ -209,7 +212,8 @@ bool Node::misc_empty() const * @param value is the value to backtrack to. * @return True if the future value was successully added; false otherwise */ -bool Node::add_future_value(uint64_t value, modelclock_t expiration) { +bool Node::add_future_value(uint64_t value, modelclock_t expiration) +{ int idx = -1; /* Highest index where value is found */ for (unsigned int i = 0; i < future_values.size(); i++) { if (future_values[i].value == value) { @@ -386,7 +390,8 @@ int Node::get_read_from_size() const return may_read_from.size(); } -const ModelAction * Node::get_read_from_at(int i) { +const ModelAction * Node::get_read_from_at(int i) const +{ return may_read_from[i]; } @@ -407,7 +412,8 @@ const ModelAction * Node::get_read_from() const * Increments the index into the readsfrom set to explore the next item. * @return Returns false if we have explored all items. */ -bool Node::increment_read_from() { +bool Node::increment_read_from() +{ DBG(); promises.clear(); if (read_from_index < may_read_from.size()) { @@ -421,7 +427,8 @@ bool Node::increment_read_from() { * Increments the index into the future_values set to explore the next item. * @return Returns false if we have explored all values. */ -bool Node::increment_future_value() { +bool Node::increment_future_value() +{ DBG(); promises.clear(); if (future_index < ((int)future_values.size())) {