debug: CPPFLAGS += -DCONFIG_DEBUG
debug: all
-mac: CPPFLAGS += -D_XOPEN_SOURCE -DMAC
+mac: CPPFLAGS += -D_XOPEN_SOURCE -DMAC -DCONFIG_DEBUG
mac: LDFLAGS=-ldl
mac: SHARED=-Wl,-undefined,dynamic_lookup -dynamiclib
mac: all
/** Initializes a CycleGraph object. */
CycleGraph::CycleGraph() :
hasCycles(false),
- oldCycles(false)
+ oldCycles(false),
+ hasRMWViolation(false),
+ oldRMWViolation(false)
{
}
/* Two RMW actions cannot read from the same write. */
if (fromnode->setRMW(rmwnode)) {
- hasCycles=true;
+ hasRMWViolation=true;
} else {
rmwrollbackvector.push_back(fromnode);
}
ASSERT(rollbackvector.size()==0);
ASSERT(rmwrollbackvector.size()==0);
ASSERT(oldCycles==hasCycles);
+ ASSERT(oldRMWViolation==hasRMWViolation);
}
/** Commit changes to the cyclegraph. */
rollbackvector.resize(0);
rmwrollbackvector.resize(0);
oldCycles=hasCycles;
+ oldRMWViolation=hasRMWViolation;
}
/** Rollback changes to the previous commit. */
}
hasCycles = oldCycles;
+ hasRMWViolation = oldRMWViolation;
rollbackvector.resize(0);
rmwrollbackvector.resize(0);
}
return hasCycles;
}
+bool CycleGraph::checkForRMWViolation() {
+ return hasRMWViolation;
+}
+
/**
* Constructor for a CycleNode.
* @param modelaction The ModelAction for this node
~CycleGraph();
void addEdge(const ModelAction *from, const ModelAction *to);
bool checkForCycles();
+ bool checkForRMWViolation();
void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
bool checkReachable(const ModelAction *from, const ModelAction *to);
/** @brief A flag: true if this graph contains cycles */
bool hasCycles;
-
bool oldCycles;
+ bool hasRMWViolation;
+ bool oldRMWViolation;
+
std::vector<CycleNode *> rollbackvector;
std::vector<CycleNode *> rmwrollbackvector;
};
mo_graph->commitChanges();
updated |= r_status;
- } else {
+ } else if (!second_part_of_rmw) {
/* Read from future value */
value = curr->get_node()->get_future_value();
modelclock_t expiration = curr->get_node()->get_future_value_expiration();
/** @returns whether the current partial trace is feasible. */
bool ModelChecker::isfeasible() {
+ return !mo_graph->checkForRMWViolation() && isfeasibleotherthanRMW();
+}
+
+/** @returns whether the current partial trace is feasible. */
+bool ModelChecker::isfeasibleotherthanRMW() {
return !mo_graph->checkForCycles() && !failed_promise && !too_many_reads && !promises_expired();
}
=>
that read could potentially read from our write.
*/
- if (isfeasible() && act->get_node()->add_future_value(curr->get_value(), curr->get_seq_number()+params.maxfuturedelay) &&
- (!priv->next_backtrack || *act > *priv->next_backtrack))
- priv->next_backtrack = act;
+ if (thin_air_constraint_may_allow(curr, act)) {
+ if (isfeasible() ||
+ (curr->is_rmw() && act->is_rmw() && curr->get_reads_from()==act->get_reads_from() && isfeasibleotherthanRMW())) {
+ if (act->get_node()->add_future_value(curr->get_value(), curr->get_seq_number()+params.maxfuturedelay) &&
+ (!priv->next_backtrack || *act > *priv->next_backtrack))
+ priv->next_backtrack = act;
+ }
+ }
}
}
}
return added;
}
+/** Arbitrary reads from the future are not allowed. Section 29.3
+ * part 9 places some constraints. This method checks one result of constraint
+ * constraint. Others require compiler support. */
+
+bool ModelChecker::thin_air_constraint_may_allow(const ModelAction * writer, const ModelAction *reader) {
+ if (!writer->is_rmw())
+ return true;
+
+ if (!reader->is_rmw())
+ return true;
+
+ for(const ModelAction *search=writer->get_reads_from();search!=NULL;search=search->get_reads_from()) {
+ if (search==reader)
+ return false;
+ if (search->get_tid()==reader->get_tid()&&
+ search->happens_before(reader))
+ break;
+ }
+
+ return true;
+}
+
+
/**
* Finds the head(s) of the release sequence(s) containing a given ModelAction.
* The ModelAction under consideration is expected to be taking part in
bool ModelChecker::resolve_promises(ModelAction *write)
{
bool resolved = false;
+
for (unsigned int i = 0, promise_index = 0; promise_index < promises->size(); i++) {
Promise *promise = (*promises)[promise_index];
if (write->get_node()->get_promise(i)) {
} else
promise_index++;
}
-
return resolved;
}
if (curr) {
if (curr->get_state() == THREAD_READY) {
ASSERT(priv->current_action);
+
priv->nextThread = check_current_action(priv->current_action);
priv->current_action = NULL;
if (!curr->is_blocked() && !curr->is_complete())
ModelAction * get_parent_action(thread_id_t tid);
bool next_execution();
bool isfeasible();
+ bool isfeasibleotherthanRMW();
bool isfinalfeasible();
void check_promises(ClockVector *old_cv, ClockVector * merge_cv);
void get_release_seq_heads(ModelAction *act,
std::vector<const ModelAction *> *release_heads);
-
void finish_execution();
bool isfeasibleprefix();
void set_assert() {asserted=true;}
private:
/** The scheduler to use: tracks the running/ready Threads */
Scheduler *scheduler;
-
+
+ bool thin_air_constraint_may_allow(const ModelAction * writer, const ModelAction *reader);
bool has_asserted() {return asserted;}
void reset_asserted() {asserted=false;}
int num_executions;