more mutex changes
authorBrian Demsky <bdemsky@uci.edu>
Wed, 19 Sep 2012 23:38:33 +0000 (16:38 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Wed, 19 Sep 2012 23:38:33 +0000 (16:38 -0700)
model.cc
mutex.cc
mutex.h

index 651d32d5b9c7bf74a63bbfda817419009a1e6049..6732c265e9534a426a0aed9391303a2754faeda6 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -337,6 +337,10 @@ void ModelChecker::process_mutex(ModelAction *curr) {
        }
                //otherwise fall into the lock case
        case ATOMIC_LOCK: {
+               if (curr->get_cv()->getClock(state->alloc_tid)<=state->alloc_clock) {
+                       printf("Lock access before initialization\n");
+                       set_assert();
+               }
                state->islocked=true;
                ModelAction *unlock=get_last_unlock(curr);
                //synchronize with the previous unlock statement
index 2cf6828af0ac679811d0fe7cac42d57502fe60d9..51315d94bbf3081959c4c59d1d4c6af727f4a7ea 100644 (file)
--- a/mutex.cc
+++ b/mutex.cc
@@ -1,10 +1,12 @@
 #include "mutex.h"
 #include "model.h"
 
-
 namespace std {
 mutex::mutex() {
        state.islocked=false;
+       thread_id_t tid=thread_current()->get_id();
+       state.alloc_tid=tid;
+       state.alloc_clock=model->get_cv(tid)->getClock(tid);
 }
        
 void mutex::lock() {
diff --git a/mutex.h b/mutex.h
index a65250b542fafd68a28ab089131d0a4937694784..828aae53f9e1d273900b776ab657907c87e3cd08 100644 (file)
--- a/mutex.h
+++ b/mutex.h
@@ -1,10 +1,13 @@
 #ifndef MUTEX_H
 #define MUTEX_H
 #include "threads.h"
+#include "clockvector.h"
 
 namespace std {
        struct mutex_state {
                bool islocked;
+               thread_id_t alloc_tid;
+               modelclock_t alloc_clock;
        };
 
        class mutex {