From 17e0164944342a21d72d1de5e77d633cf3c2a307 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 28 May 2012 10:16:34 -0700 Subject: [PATCH] nodestack: construct Node with 'number of threads', not 'parent node' I don't really want to base the number of threads off of a 'parent'; I can just record the global 'number of threads' as a Node parameter. --- nodestack.cc | 12 ++++-------- nodestack.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nodestack.cc b/nodestack.cc index 4cbd7ce..1d2bc96 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -1,21 +1,17 @@ #include "nodestack.h" #include "action.h" #include "common.h" +#include "model.h" int Node::total_nodes = 0; -Node::Node(ModelAction *act, Node *parent) +Node::Node(ModelAction *act, int nthreads) : action(act), - num_threads(parent ? parent->num_threads : 1), + num_threads(nthreads), explored_children(num_threads), backtrack(num_threads) { total_nodes++; - if (act && act->get_type() == THREAD_CREATE) { - num_threads++; - explored_children.resize(num_threads); - backtrack.resize(num_threads); - } } Node::~Node() @@ -140,7 +136,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act) /* Record action */ get_head()->explore_child(act); act->create_cv(get_head()->get_action()); - node_list.push_back(new Node(act, get_head())); + node_list.push_back(new Node(act, model->get_num_threads())); iter++; } return (*iter)->get_action(); diff --git a/nodestack.h b/nodestack.h index eebfa5b..cf3c6db 100644 --- a/nodestack.h +++ b/nodestack.h @@ -11,7 +11,7 @@ class ModelAction; class Node { public: - Node(ModelAction *act = NULL, Node *parent = NULL); + Node(ModelAction *act = NULL, int nthreads = 1); ~Node(); /* return true = thread choice has already been explored */ bool has_been_explored(thread_id_t tid); -- 2.34.1