action: add 'reads_from' member variable
authorBrian Norris <banorris@uci.edu>
Wed, 11 Jul 2012 21:10:40 +0000 (14:10 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 11 Jul 2012 21:22:01 +0000 (14:22 -0700)
Just printed out for now, but the 'reads_from' parameter might be used more
later.

action.cc
action.h

index f41b0eba7643e18a912b776c71470eddf71a1bf7..c96949bc906cc02a9ca3cb50af761a92feda94c7 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -10,6 +10,7 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int
        order(order),
        location(loc),
        value(value),
+       reads_from(NULL),
        cv(NULL)
 {
        Thread *t = thread_current();
@@ -132,6 +133,7 @@ void ModelAction::read_from(const ModelAction *act)
        ASSERT(cv);
        if (act->is_release() && this->is_acquire())
                cv->merge(act->cv);
+       reads_from = act;
        value = act->value;
 }
 
@@ -175,8 +177,10 @@ void ModelAction::print(void) const
                type_str = "unknown type";
        }
 
-       printf("(%3d) Thread: %-2d    Action: %-13s    MO: %d    Loc: %14p    Value: %d",
+       printf("(%3d) Thread: %-2d    Action: %-13s    MO: %d    Loc: %14p    Value: %-4d",
                        seq_number, id_to_int(tid), type_str, order, location, value);
+       if (reads_from)
+               printf(" Rf: %d", reads_from->get_seq_number());
        if (cv) {
                printf("\t");
                cv->print();
index 4504fd8c089c71eaa60e10d25ecbbba61c26ec5f..731c3192f747b083bc0f26e6b0961c432bc90514 100644 (file)
--- a/action.h
+++ b/action.h
@@ -47,6 +47,7 @@ public:
        void * get_location() const { return location; }
        modelclock_t get_seq_number() const { return seq_number; }
        int get_value() const { return value; }
+       const ModelAction * get_reads_from() const { return reads_from; }
 
        Node * get_node() const { return node; }
        void set_node(Node *n) { node = n; }
@@ -94,6 +95,9 @@ private:
         * should probably be something longer. */
        int value;
 
+       /** The action that this action reads from. Only valid for reads */
+       const ModelAction *reads_from;
+
        /** A back reference to a Node in NodeStack, if this ModelAction is
         * saved on the NodeStack. */
        Node *node;