/* First thread created will have id INITIAL_THREAD_ID */
next_thread_id(INITIAL_THREAD_ID),
used_sequence_numbers(0),
-
num_executions(0),
current_action(NULL),
diverge(NULL),
}
} else if (curr->is_write()) {
w_modification_order(curr);
+ resolve_promises(curr);
}
th->set_return_value(value);
return get_parent_action(tid)->get_cv();
}
+
+/** Resolve promises. */
+
+void ModelChecker::resolve_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()) {
+
+
+ }
+ }
+}
+
/** Checks promises in response to change in ClockVector Threads. */
void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
action_list_t::reverse_iterator rit;
for (rit = list->rbegin(); rit != list->rend(); rit++) {
ModelAction *act = *rit;
-
+
/* Only consider 'write' actions */
if (!act->is_write())
continue;
thread_id_t get_next_replay_thread();
ModelAction * get_next_backtrack();
void reset_to_initial_state();
+ void resolve_promises(ModelAction *curr);
void add_action_to_lists(ModelAction *act);
ModelAction * get_last_action(thread_id_t tid);
(*it)->print();
}
+void Node::set_promise(uint32_t i) {
+ if (i>=promises.size())
+ promises.resize(i+1,0);
+ promises[i]=1;
+}
+
+bool Node::get_promise(uint32_t i) {
+ return (promises[i]==2);
+}
+
+bool Node::increment_promises() {
+ for (unsigned int i=0;i<promises.size();i++) {
+ if (promises[i]==1) {
+ promises[i]=2;
+ do {
+ i--;
+ if (promises[i]==2)
+ promises[i]=1;
+ } while(i>0);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool Node::promises_empty() {
+ for (unsigned int i=0;i<promises.size();i++)
+ if (promises[i]==1)
+ return false;
+ return true;
+}
+
/**
* Adds a value from a weakly ordered future write to backtrack to.
* @param value is the value to backtrack to.
*/
bool Node::add_future_value(uint64_t value) {
- for(int i=0;i<future_values.size();i++)
+ for(unsigned int i=0;i<future_values.size();i++)
if (future_values[i]==value)
return false;
future_values.push_back(value);
return true;
}
+/**
+ * Checks whether the future_values set for this node is empty.
+ * @return true if the future_values set is empty.
+ */
+
+bool Node::futurevalues_empty() {
+ return ((future_index+1)>=future_values.size());
+}
+
/**
* Checks if the Thread associated with this thread ID has been explored from
return ((read_from_index+1)>=may_read_from.size());
}
-/**
- * Checks whether the future_values set for this node is empty.
- * @return true if the future_values set is empty.
- */
-bool Node::futurevalues_empty() {
- return ((future_index+1)>=future_values.size());
-}
/**
* Mark the appropriate backtracking information for exploring a thread choice.
typedef std::vector< const ModelAction *, MyAlloc< const ModelAction * > > readfrom_set_t;
typedef std::vector< uint64_t, MyAlloc< uint64_t > > futurevalues_t;
+typedef std::vector< uint32_t, MyAlloc< uint32_t > > promises_t;
/**
* @brief A single node in a NodeStack
bool has_been_explored(thread_id_t tid);
/* return true = backtrack set is empty */
bool backtrack_empty();
- bool readsfrom_empty();
- bool futurevalues_empty();
+
void explore_child(ModelAction *act);
/* return false = thread was already in backtrack */
bool set_backtrack(thread_id_t id);
Node * get_parent() const { return parent; }
bool add_future_value(uint64_t value);
+ uint64_t get_future_value();
+ bool increment_future_values();
+ bool futurevalues_empty();
+
void add_read_from(const ModelAction *act);
const ModelAction * get_read_from();
- uint64_t get_future_value();
bool increment_read_from();
- bool increment_future_values();
+ bool readsfrom_empty();
+
+ void set_promise(uint32_t i);
+ bool get_promise(uint32_t i);
+ bool increment_promises();
+ bool promises_empty();
void print();
void print_may_read_from();
unsigned int read_from_index;
futurevalues_t future_values;
+ promises_t promises;
unsigned int future_index;
};
Promise(ModelAction * act, uint64_t value);
const ModelAction * get_action() { return read; }
int increment_threads() { return ++numthreads; }
+ uint64_t get_value() { return value; }
private:
uint64_t value;