+/**
+ * Returns the clock vector for a given thread.
+ * @param tid The thread whose clock vector we want
+ * @return Desired clock vector
+ */
+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];
+ if (write->get_node()->get_promise(i)) {
+ ModelAction * read=promise->get_action();
+ read->read_from(write);
+ r_modification_order(read, write);
+ 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)&&
+ 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))&&
+ 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();
+ if (num_synchronized_threads==model->get_num_threads()) {
+ //Promise has failed
+ failed_promise = true;
+ return;
+ }
+ }
+ }
+}
+
+/**
+ * Build up an initial set of all past writes that this 'read' action may read
+ * from. This set is determined by the clock vector's "happens before"
+ * relationship.
+ * @param curr is the current ModelAction that we are exploring; it must be a
+ * 'read' operation.
+ */
+void ModelChecker::build_reads_from_past(ModelAction *curr)