projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add support for sleep sets...
[model-checker.git]
/
nodestack.cc
diff --git
a/nodestack.cc
b/nodestack.cc
index 136e3a2eb4a2f72325db5e95e5fc9205160450b2..76d167d82a9438e6cd941d114c5a172867ca0780 100644
(file)
--- a/
nodestack.cc
+++ b/
nodestack.cc
@@
-4,6
+4,7
@@
#include "action.h"
#include "common.h"
#include "model.h"
#include "action.h"
#include "common.h"
#include "model.h"
+#include "threads.h"
/**
* @brief Node constructor
/**
* @brief Node constructor
@@
-46,7
+47,7
@@
Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness)
if (prevfi) {
*fi=*prevfi;
}
if (prevfi) {
*fi=*prevfi;
}
- if (parent->enabled_array[i]) {
+ if (parent->enabled_array[i]
==THREAD_ENABLED
) {
fi->enabled_count++;
}
if (i==currtid) {
fi->enabled_count++;
}
if (i==currtid) {
@@
-55,7
+56,7
@@
Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness)
}
//Do window processing
if (prevfairness != NULL) {
}
//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--;
fi->enabled_count--;
if (i==prevtid) {
fi->turns--;
@@
-77,7
+78,7
@@
Node::~Node()
if (action)
delete action;
if (enabled_array)
if (action)
delete action;
if (enabled_array)
-
MYFREE
(enabled_array);
+
model_free
(enabled_array);
}
/** Prints debugging info for the ModelAction associated with this Node */
}
/** Prints debugging info for the ModelAction associated with this Node */
@@
-158,7
+159,7
@@
bool Node::add_future_value(uint64_t value, modelclock_t expiration) {
if (future_values[i].value == value) {
if (future_values[i].expiration>=expiration)
return false;
if (future_values[i].value == value) {
if (future_values[i].expiration>=expiration)
return false;
- if (future_index <
i
) {
+ if (future_index <
((int) i)
) {
suitableindex=i;
}
}
suitableindex=i;
}
}
@@
-178,7
+179,7
@@
bool Node::add_future_value(uint64_t value, modelclock_t expiration) {
* @return true if the future_values set is empty.
*/
bool Node::future_value_empty() {
* @return true if the future_values set is empty.
*/
bool Node::future_value_empty() {
- return ((future_index + 1) >=
future_values.size(
));
+ return ((future_index + 1) >=
((int)future_values.size()
));
}
/**
}
/**
@@
-215,15
+216,15
@@
bool Node::read_from_empty() {
* Mark the appropriate backtracking information for exploring a thread choice.
* @param act The ModelAction to explore
*/
* 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 )
{
if ( ! enabled_array )
- enabled_array=(
bool *)MYMALLOC(sizeof(bool
)*num_threads);
+ enabled_array=(
enabled_type_t *)model_malloc(sizeof(enabled_type_t
)*num_threads);
if (is_enabled != NULL)
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++)
else {
for(int i=0;i<num_threads;i++)
- enabled_array[i]=
false
;
+ enabled_array[i]=
THREAD_DISABLED
;
}
explore(act->get_tid());
}
explore(act->get_tid());
@@
-264,13
+265,18
@@
thread_id_t Node::get_next_backtrack()
bool Node::is_enabled(Thread *t)
{
int thread_id=id_to_int(t->get_id());
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_DISABLED)
;
}
bool Node::is_enabled(thread_id_t tid)
{
int thread_id=id_to_int(tid);
}
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_DISABLED);
+}
+
+bool Node::has_priority(thread_id_t tid)
+{
+ return fairness[id_to_int(tid)].priority;
}
/**
}
/**
@@
-288,12
+294,12
@@
void Node::add_read_from(const ModelAction *act)
* @return The first element in future_values
*/
uint64_t Node::get_future_value() {
* @return The first element in future_values
*/
uint64_t Node::get_future_value() {
- ASSERT(future_index<
future_values.size(
));
+ ASSERT(future_index<
((int)future_values.size()
));
return future_values[future_index].value;
}
modelclock_t Node::get_future_value_expiration() {
return future_values[future_index].value;
}
modelclock_t Node::get_future_value_expiration() {
- ASSERT(future_index<
future_values.size(
));
+ ASSERT(future_index<
((int)future_values.size()
));
return future_values[future_index].expiration;
}
return future_values[future_index].expiration;
}
@@
-325,8
+331,11
@@
const ModelAction * Node::get_read_from() {
bool Node::increment_read_from() {
DBG();
promises.clear();
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;
}
/**
}
/**
@@
-336,8
+345,11
@@
bool Node::increment_read_from() {
bool Node::increment_future_value() {
DBG();
promises.clear();
bool Node::increment_future_value() {
DBG();
promises.clear();
- future_index++;
- return (future_index < 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)
}
void Node::explore(thread_id_t tid)
@@
-350,16
+362,18
@@
void Node::explore(thread_id_t tid)
explored_children[i] = true;
}
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++;
total_nodes++;
- iter = 0;
}
NodeStack::~NodeStack()
{
}
NodeStack::~NodeStack()
{
+ for (unsigned int i = 0; i < node_list.size(); i++)
+ delete node_list[i];
}
void NodeStack::print()
}
void NodeStack::print()
@@
-377,7
+391,7
@@
void NodeStack::print()
/** Note: The is_enabled set contains what actions were enabled when
* act was chosen. */
/** 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();
{
DBG();
@@
-412,6
+426,8
@@
void NodeStack::pop_restofstack(int numAhead)
{
/* Diverging from previous execution; clear out remainder of list */
unsigned int it=iter+numAhead;
{
/* 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);
}
node_list.resize(it);
}