fix scheduling stuff to get nice round robin scheduler behavior...
[model-checker.git] / nodestack.cc
index addf93f67469f1cd7f96a15ffad8ec5551cb1c1b..9c0df20b5de89bd2876cde69ca281502506f4709 100644 (file)
@@ -226,7 +226,7 @@ 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(struct future_value& fv)
+bool Node::add_future_value(struct future_value fv)
 {
        uint64_t value = fv.value;
        modelclock_t expiration = fv.expiration;
@@ -348,6 +348,14 @@ thread_id_t Node::get_next_backtrack()
        return int_to_id(i);
 }
 
+void Node::clear_backtracking()
+{
+       for (unsigned int i = 0; i < backtrack.size(); i++)
+               backtrack[i] = false;
+       for (unsigned int i = 0; i < explored_children.size(); i++)
+               explored_children[i] = false;
+}
+
 bool Node::is_enabled(Thread *t) const
 {
        int thread_id = id_to_int(t->get_id());
@@ -556,7 +564,11 @@ ModelAction * NodeStack::explore_action(ModelAction *act, enabled_type_t *is_ena
                if (model->params.fairwindow != 0 && head_idx > (int)model->params.fairwindow)
                        prevfairness = node_list[head_idx - model->params.fairwindow];
        }
-       node_list.push_back(new Node(act, head, model->get_num_threads(), prevfairness));
+
+       int next_threads = model->get_num_threads();
+       if (act->get_type() == THREAD_CREATE)
+               next_threads++;
+       node_list.push_back(new Node(act, head, next_threads, prevfairness));
        total_nodes++;
        head_idx++;
        return NULL;
@@ -577,6 +589,7 @@ void NodeStack::pop_restofstack(int numAhead)
        for (unsigned int i = it; i < node_list.size(); i++)
                delete node_list[i];
        node_list.resize(it);
+       node_list.back()->clear_backtracking();
 }
 
 Node * NodeStack::get_head() const