add new option for uninitialized writes...
[model-checker.git] / action.cc
index 1007e762ee5258305bbd8ef5b403db5a874f17cc..4b380c2dd404fafc1b4be9846433967daa8cd167 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -151,6 +151,11 @@ bool ModelAction::could_be_write() const
        return is_write() || is_rmwr();
 }
 
+bool ModelAction::is_yield() const
+{
+       return type == THREAD_YIELD;
+}
+
 bool ModelAction::is_rmwr() const
 {
        return type == ATOMIC_RMWR;
@@ -651,3 +656,17 @@ bool ModelAction::may_read_from(const Promise *promise) const
                        return true;
        return false;
 }
+
+/**
+ * Only valid for LOCK, TRY_LOCK, UNLOCK, and WAIT operations.
+ * @return The mutex operated on by this action, if any; otherwise NULL
+ */
+std::mutex * ModelAction::get_mutex() const
+{
+       if (is_trylock() || is_lock() || is_unlock())
+               return (std::mutex *)get_location();
+       else if (is_wait())
+               return (std::mutex *)get_value();
+       else
+               return NULL;
+}