#include "action.h"
#include "common.h"
#include "model.h"
+#include "threads.h"
/**
* @brief Node constructor
if (prevfi) {
*fi=*prevfi;
}
- if (parent->enabled_array[i]) {
+ if (parent->enabled_array[i]==THREAD_ENABLED) {
fi->enabled_count++;
}
if (i==currtid) {
}
//Do window processing
if (prevfairness != NULL) {
- if (prevfairness -> parent->enabled_array[i])
+ if (prevfairness -> parent->enabled_array[i] == THREAD_ENABLED)
fi->enabled_count--;
if (i==prevtid) {
fi->turns--;
* Mark the appropriate backtracking information for exploring a thread choice.
* @param act The ModelAction to explore
*/
-void Node::explore_child(ModelAction *act, bool * is_enabled)
+void Node::explore_child(ModelAction *act, enabled_type_t * is_enabled)
{
if ( ! enabled_array )
- enabled_array=(bool *)model_malloc(sizeof(bool)*num_threads);
+ enabled_array=(enabled_type_t *)model_malloc(sizeof(enabled_type_t)*num_threads);
if (is_enabled != NULL)
- memcpy(enabled_array, is_enabled, sizeof(bool)*num_threads);
+ memcpy(enabled_array, is_enabled, sizeof(enabled_type_t)*num_threads);
else {
for(int i=0;i<num_threads;i++)
- enabled_array[i]=false;
+ enabled_array[i]=THREAD_DISABLED;
}
explore(act->get_tid());
bool Node::is_enabled(Thread *t)
{
int thread_id=id_to_int(t->get_id());
- return thread_id < num_threads && enabled_array[thread_id];
+ return thread_id < num_threads && (enabled_array[thread_id] == THREAD_ENABLED);
}
bool Node::is_enabled(thread_id_t tid)
{
int thread_id=id_to_int(tid);
- return thread_id < num_threads && enabled_array[thread_id];
+ return thread_id < num_threads && (enabled_array[thread_id] == THREAD_ENABLED);
+}
+
+bool Node::has_priority(thread_id_t tid)
+{
+ return fairness[id_to_int(tid)].priority;
}
/**
bool Node::increment_read_from() {
DBG();
promises.clear();
- read_from_index++;
- return (read_from_index < may_read_from.size());
+ if (read_from_index < may_read_from.size()) {
+ read_from_index++;
+ return read_from_index < may_read_from.size();
+ }
+ return false;
}
/**
bool Node::increment_future_value() {
DBG();
promises.clear();
- future_index++;
- return (future_index < (int)future_values.size());
+ if (future_index < ((int)future_values.size())) {
+ future_index++;
+ return (future_index < ((int)future_values.size()));
+ }
+ return false;
}
void Node::explore(thread_id_t tid)
explored_children[i] = true;
}
-NodeStack::NodeStack()
- : total_nodes(0)
+NodeStack::NodeStack() :
+ node_list(1, new Node()),
+ iter(0),
+ total_nodes(0)
{
- node_list.push_back(new Node());
total_nodes++;
- iter = 0;
}
NodeStack::~NodeStack()
{
+ for (unsigned int i = 0; i < node_list.size(); i++)
+ delete node_list[i];
}
void NodeStack::print()
/** Note: The is_enabled set contains what actions were enabled when
* act was chosen. */
-ModelAction * NodeStack::explore_action(ModelAction *act, bool * is_enabled)
+ModelAction * NodeStack::explore_action(ModelAction *act, enabled_type_t * is_enabled)
{
DBG();
{
/* Diverging from previous execution; clear out remainder of list */
unsigned int it=iter+numAhead;
+ for(unsigned int i=it;i<node_list.size();i++)
+ delete node_list[i];
node_list.resize(it);
}