X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=cyclegraph.h;h=2e523d7950b28c5b91830217414eebbc459d2972;hp=a748c7791110f5c37837ff72131bc8901b98e4e5;hb=379bbd92e88f756e39883dbac98c68b1d0699a66;hpb=8548c711d71b6474802af83f5a4800eb4ac30718 diff --git a/cyclegraph.h b/cyclegraph.h index a748c77..2e523d7 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -1,3 +1,7 @@ +/** @file cyclegraph.h @brief Data structure to track ordering + * constraints on modification order. The idea is to see whether a + * total order exists that satisfies the ordering constriants.*/ + #ifndef CYCLEGRAPH_H #define CYCLEGRAPH_H @@ -12,26 +16,44 @@ class ModelAction; class CycleGraph { public: CycleGraph(); - void addEdge(ModelAction *from, ModelAction *to); + ~CycleGraph(); + void addEdge(const ModelAction *from, const ModelAction *to); bool checkForCycles(); + void addRMWEdge(const ModelAction *from, const ModelAction *rmw); + + bool checkReachable(const ModelAction *from, const ModelAction *to); private: - CycleNode * getNode(ModelAction *); - HashTable actionToNode; + CycleNode * getNode(const ModelAction *); + + /** @brief A table for mapping ModelActions to CycleNodes */ + HashTable actionToNode; + bool checkReachable(CycleNode *from, CycleNode *to); - bool hasCycles; + /** @brief A flag: true if this graph contains cycles */ + bool hasCycles; }; +/** @brief A node within a CycleGraph; corresponds to one ModelAction */ class CycleNode { public: - CycleNode(ModelAction *action); + CycleNode(const ModelAction *action); void addEdge(CycleNode * node); std::vector * getEdges(); + bool setRMW(CycleNode *); + CycleNode* getRMW(); private: - ModelAction *action; + /** @brief The ModelAction that this node represents */ + const ModelAction *action; + + /** @brief The edges leading out from this node */ std::vector edges; + + /** Pointer to a RMW node that reads from this node, or NULL, if none + * exists */ + CycleNode * hasRMW; }; #endif