* @param tid The thread whose clock vector we want
* @return Desired clock vector
*/
-ClockVector * ModelChecker::get_cv(thread_id_t tid) {
+ClockVector * ModelChecker::get_cv(thread_id_t tid)
+{
return get_parent_action(tid)->get_cv();
}
-
/** Resolve the given promises. */
-
-void ModelChecker::resolve_promises(ModelAction *write) {
- for (unsigned int i = 0, promise_index = 0;promise_index<promises->size(); i++) {
- Promise * promise = (*promises)[promise_index];
+void ModelChecker::resolve_promises(ModelAction *write)
+{
+ for (unsigned int i = 0, promise_index = 0; promise_index < promises->size(); i++) {
+ Promise *promise = (*promises)[promise_index];
if (write->get_node()->get_promise(i)) {
- ModelAction * read = promise->get_action();
+ ModelAction *read = promise->get_action();
read->read_from(write);
r_modification_order(read, write);
post_r_modification_order(read, write);
- promises->erase(promises->begin()+promise_index);
+ promises->erase(promises->begin() + promise_index);
} else
promise_index++;
}
/** Compute the set of promises that could potentially be satisfied by
* this action. */
-
-void ModelChecker::compute_promises(ModelAction *curr) {
- for (unsigned int i = 0;i<promises->size();i++) {
- Promise * promise = (*promises)[i];
- const ModelAction * act = promise->get_action();
- if (!act->happens_before(curr)&&
- act->is_read()&&
- !act->is_synchronizing(curr)&&
- !act->same_thread(curr)&&
+void ModelChecker::compute_promises(ModelAction *curr)
+{
+ for (unsigned int i = 0; i < promises->size(); i++) {
+ Promise *promise = (*promises)[i];
+ const ModelAction *act = promise->get_action();
+ if (!act->happens_before(curr) &&
+ act->is_read() &&
+ !act->is_synchronizing(curr) &&
+ !act->same_thread(curr) &&
promise->get_value() == curr->get_value()) {
curr->get_node()->set_promise(i);
}
}
/** Checks promises in response to change in ClockVector Threads. */
-
-void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
- for (unsigned int i = 0;i<promises->size();i++) {
- Promise * promise = (*promises)[i];
- const ModelAction * act = promise->get_action();
- if ((old_cv == NULL||!old_cv->synchronized_since(act))&&
+void ModelChecker::check_promises(ClockVector *old_cv, ClockVector *merge_cv)
+{
+ for (unsigned int i = 0; i < promises->size(); i++) {
+ Promise *promise = (*promises)[i];
+ const ModelAction *act = promise->get_action();
+ if ((old_cv == NULL || !old_cv->synchronized_since(act)) &&
merge_cv->synchronized_since(act)) {
//This thread is no longer able to send values back to satisfy the promise
int num_synchronized_threads = promise->increment_threads();
* @param i is the promise index.
*/
void Node::set_promise(unsigned int i) {
- if (i>=promises.size())
- promises.resize(i+1,0);
- promises[i]=1;
+ if (i >= promises.size())
+ promises.resize(i + 1, 0);
+ promises[i] = 1;
}
/**
* @return true if the promise should be satisfied by the given model action.
*/
bool Node::get_promise(unsigned int i) {
- return (i<promises.size())&&(promises[i]==2);
+ return (i < promises.size()) && (promises[i] == 2);
}
/**
* @return true if we have a valid combination.
*/
bool Node::increment_promise() {
- for (unsigned int i=0;i<promises.size();i++) {
- if (promises[i]==1) {
- promises[i]=2;
- while (i>0) {
+ for (unsigned int i = 0; i < promises.size(); i++) {
+ if (promises[i] == 1) {
+ promises[i] = 2;
+ while (i > 0) {
i--;
- if (promises[i]==2)
- promises[i]=1;
+ if (promises[i] == 2)
+ promises[i] = 1;
}
return true;
}
* @return true if we have explored all promise combinations.
*/
bool Node::promise_empty() {
- for (unsigned int i=0;i<promises.size();i++)
- if (promises[i]==1)
+ for (unsigned int i = 0; i < promises.size();i++)
+ if (promises[i] == 1)
return false;
return true;
}
* @param value is the value to backtrack to.
*/
bool Node::add_future_value(uint64_t value) {
- for(unsigned int i=0;i<future_values.size();i++)
- if (future_values[i]==value)
+ for (unsigned int i = 0; i < future_values.size(); i++)
+ if (future_values[i] == value)
return false;
future_values.push_back(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());
}
/**
* @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());
}
/**
* @return The first element in may_read_from
*/
const ModelAction * Node::get_read_from() {
- if (read_from_index<may_read_from.size())
+ if (read_from_index < may_read_from.size())
return may_read_from[read_from_index];
else
return NULL;
*/
bool Node::increment_read_from() {
read_from_index++;
- return (read_from_index<may_read_from.size());
+ return (read_from_index < may_read_from.size());
}
/**
*/
bool Node::increment_future_value() {
future_index++;
- return (future_index<future_values.size());
+ return (future_index < future_values.size());
}
void Node::explore(thread_id_t tid)