X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=2280e76e3e208b8ac6ce6e2044433c1a866d2c85;hb=2c830a91c32a55de67c21e03f36529f994d9139d;hp=2bfe76ac424c274bf8152638543ad7dd6bc1d31f;hpb=0170878f8a8be6aa06af6591e50fffdb2ce54022;p=model-checker.git diff --git a/cyclegraph.cc b/cyclegraph.cc index 2bfe76a..2280e76 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -1,6 +1,8 @@ #include "cyclegraph.h" #include "action.h" #include "common.h" +#include "promise.h" +#include "model.h" /** Initializes a CycleGraph object. */ CycleGraph::CycleGraph() : @@ -122,11 +124,7 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) { } #if SUPPORT_MOD_ORDER_DUMP -void CycleGraph::dumpGraphToFile(const char *filename) { - char buffer[200]; - sprintf(buffer, "%s.dot",filename); - FILE *file=fopen(buffer, "w"); - fprintf(file, "digraph %s {\n",filename); +void CycleGraph::dumpNodes(FILE *file) { for(unsigned int i=0;i * edges=cn->getEdges(); @@ -141,6 +139,14 @@ void CycleGraph::dumpGraphToFile(const char *filename) { fprintf(file, "N%u -> N%u;\n", action->get_seq_number(), dstaction->get_seq_number()); } } +} + +void CycleGraph::dumpGraphToFile(const char *filename) { + char buffer[200]; + sprintf(buffer, "%s.dot",filename); + FILE *file=fopen(buffer, "w"); + fprintf(file, "digraph %s {\n",filename); + dumpNodes(file); fprintf(file,"}\n"); fclose(file); } @@ -169,8 +175,8 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) * @return True, @a from can reach @a to; otherwise, false */ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { - std::vector > queue; - HashTable discovered; + std::vector > queue; + HashTable discovered(64); queue.push_back(from); discovered.put(from, from); @@ -191,6 +197,33 @@ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { return false; } +bool CycleGraph::checkPromise(const ModelAction *fromact, Promise *promise) { + std::vector > queue; + HashTable discovered(64); + CycleNode *from = actionToNode.get(fromact); + + + queue.push_back(from); + discovered.put(from, from); + while(!queue.empty()) { + CycleNode * node=queue.back(); + queue.pop_back(); + + if (promise->increment_threads(node->getAction()->get_tid())) { + return true; + } + + for(unsigned int i=0;igetEdges()->size();i++) { + CycleNode *next=(*node->getEdges())[i]; + if (!discovered.contains(next)) { + discovered.put(next,next); + queue.push_back(next); + } + } + } + return false; +} + void CycleGraph::startChanges() { ASSERT(rollbackvector.size()==0); ASSERT(rmwrollbackvector.size()==0);