Merge branch 'sandbox' (remove finalize())
[model-checker.git] / clockvector.cc
index 367fa6e2763dd6636e78d212632f6aa954cda63c..2ef8b03d9e36e22ce4ee6989ec31d20633717ed2 100644 (file)
@@ -14,8 +14,6 @@ ClockVector::ClockVector(ClockVector *parent, ModelAction *act)
        memset(clock, 0, num_threads * sizeof(int));
        if (parent)
                std::memcpy(clock, parent->clock, parent->num_threads * sizeof(int));
-       else
-               clock[0] = 1;
 
        if (act)
                clock[id_to_int(act->get_tid())] = act->get_seq_number();
@@ -51,12 +49,18 @@ void ClockVector::merge(ClockVector *cv)
        clock = clk;
 }
 
-bool ClockVector::happens_before(ModelAction *act, thread_id_t id)
+/**
+ *
+ * @return true if this ClockVector's thread has synchronized with act's
+ * thread, false otherwise. That is, this function returns:
+ * <BR><CODE>act <= cv[act->tid]</CODE>
+ */
+bool ClockVector::synchronized_since(ModelAction *act)
 {
-       int i = id_to_int(id);
+       int i = id_to_int(act->get_tid());
 
        if (i < num_threads)
-               return act->get_seq_number() < clock[i];
+               return act->get_seq_number() <= clock[i];
        return false;
 }