changes
[c11tester.git] / action.cc
index 74ba5aabcf912355197f04fb94db562b41286a21..33dbe75b22c7c3daf8f25f0b51f4a077d652e682 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -95,13 +95,25 @@ bool ModelAction::same_thread(const ModelAction *act) const
        return tid == act->tid;
 }
 
-void ModelAction::upgrade_rmw(ModelAction * act) {
-       ASSERT(is_read());
-       ASSERT(act->is_rmw());
-       //Upgrade our type to the act's type
+void ModelAction::copy_typeandorder(ModelAction * act) {
        this->type=act->type;
        this->order=act->order;
-       this->value=act->value;
+}
+
+/** This method changes an existing read part of an RMW action into either:
+ *  (1) a full RMW action in case of the completed write or
+ *  (2) a READ action in case a failed action.
+ * @todo  If the memory_order changes, we may potentially need to update our
+ * clock vector.
+ */
+void ModelAction::process_rmw(ModelAction * act) {
+       this->order=act->order;
+       if (act->is_rmwc())
+               this->type=ATOMIC_READ;
+       else if (act->is_rmw()) {
+               this->type=ATOMIC_RMW;
+               this->value=act->value;
+       }
 }
 
 /** The is_synchronizing method should only explore interleavings if:
@@ -113,7 +125,6 @@ void ModelAction::upgrade_rmw(ModelAction * act) {
  *  @param act is the action to consider exploring a reordering.
  *  @return tells whether we have to explore a reordering.
  */
-
 bool ModelAction::is_synchronizing(const ModelAction *act) const
 {
        //Same thread can't be reordered
@@ -149,14 +160,27 @@ void ModelAction::create_cv(const ModelAction *parent)
                cv = new ClockVector(NULL, this);
 }
 
+
+/** Update the model action's read_from action */
 void ModelAction::read_from(const ModelAction *act)
 {
        ASSERT(cv);
-       if (act->is_release() && this->is_acquire())
+       if (act->is_release() && this->is_acquire()) {
+               synchronized(act);
                cv->merge(act->cv);
+       }
        reads_from = act;
 }
 
+
+/** Synchronize the current thread with the thread corresponding to
+ *  the ModelAction parameter. */
+
+void ModelAction::synchronized(const ModelAction *act) {
+       model->check_promises(cv, act->cv);
+       cv->merge(act->cv);
+}
+
 /**
  * Check whether 'this' happens before act, according to the memory-model's
  * happens before relation. This is checked via the ClockVector constructs.
@@ -206,7 +230,7 @@ void ModelAction::print(void) const
                type_str = "unknown type";
        }
 
-       uint64_t valuetoprint=type==ATOMIC_READ?reads_from->value:value;
+       uint64_t valuetoprint=type==ATOMIC_READ?(reads_from!=NULL?reads_from->value:VALUE_NONE):value;
 
        printf("(%3d) Thread: %-2d    Action: %-13s    MO: %d    Loc: %14p    Value: %-12" PRIu64,
                        seq_number, id_to_int(tid), type_str, order, location, valuetoprint);