rename threads.h -> threads-model.h
authorBrian Norris <banorris@uci.edu>
Tue, 9 Oct 2012 19:05:32 +0000 (12:05 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 9 Oct 2012 21:15:03 +0000 (14:15 -0700)
There's a name conflict with the C11 <threads.h>
We might as well just avoid the conflict entirely

16 files changed:
action.cc
clockvector.cc
cmodelint.cc
datarace.cc
impatomic.cc
librace.cc
libthreads.cc
main.cc
model.cc
mutex.cc
nodestack.cc
promise.h
schedule.cc
threads-model.h [new file with mode: 0644]
threads.cc
threads.h [deleted file]

index 3aeb7377e2b328fad8b24748744274ab1386e25d..5e050810e7526408828b27c74cad76fcdef95a4b 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -7,7 +7,7 @@
 #include "action.h"
 #include "clockvector.h"
 #include "common.h"
 #include "action.h"
 #include "clockvector.h"
 #include "common.h"
-#include "threads.h"
+#include "threads-model.h"
 #include "nodestack.h"
 
 #define ACTION_INITIAL_CLOCK 0
 #include "nodestack.h"
 
 #define ACTION_INITIAL_CLOCK 0
index 2b6a4cc6822c6f202decc866c0d25956908dff85..062ac4148e6573a4f00f59ccd6b947c5d37259e7 100644 (file)
@@ -6,7 +6,7 @@
 #include "action.h"
 #include "clockvector.h"
 #include "common.h"
 #include "action.h"
 #include "clockvector.h"
 #include "common.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /**
  * Constructs a new ClockVector, given a parent ClockVector and a first
 
 /**
  * Constructs a new ClockVector, given a parent ClockVector and a first
index 6b20c2cc9c800378de4b2255fc94e7a7646516d7..7e52d10798ffc8777ebe2d7d4915055300b32c4d 100644 (file)
@@ -1,6 +1,6 @@
 #include "model.h"
 #include "cmodelint.h"
 #include "model.h"
 #include "cmodelint.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /** Performs a read action.*/
 uint64_t model_read_action(void * obj, memory_order ord) {
 
 /** Performs a read action.*/
 uint64_t model_read_action(void * obj, memory_order ord) {
index 7fe5350abb5e3198360a4f0cb473914961612565..270e52310730febec1e97956c787a06c7b670b7e 100644 (file)
@@ -1,6 +1,6 @@
 #include "datarace.h"
 #include "model.h"
 #include "datarace.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 #include <stdio.h>
 #include <cstring>
 #include "mymemory.h"
 #include <stdio.h>
 #include <cstring>
 #include "mymemory.h"
index 0a35b4b65d0513da09bdc47d81614c7d14f7ab88..65b42fe558786052ab24efdd4f7a0d26970f012a 100644 (file)
@@ -1,7 +1,7 @@
 #include "impatomic.h"
 #include "common.h"
 #include "model.h"
 #include "impatomic.h"
 #include "common.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 
 namespace std {
 
 
 namespace std {
 
index bdd6093a6b6d4ea1f8c9665219a660dc23d1a813..3c56d96925a6df6c4c8b54cd5e7a0f8e742e9764 100644 (file)
@@ -5,7 +5,7 @@
 #include "common.h"
 #include "datarace.h"
 #include "model.h"
 #include "common.h"
 #include "datarace.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 
 void store_8(void *addr, uint8_t val)
 {
 
 void store_8(void *addr, uint8_t val)
 {
index f973176ba8344a497e687b8f452fdefed031fe5e..9e34141bc1de608abdb89393a3fe63570ff25f7d 100644 (file)
@@ -1,6 +1,6 @@
 #include "libthreads.h"
 #include "common.h"
 #include "libthreads.h"
 #include "common.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /* global "model" object */
 #include "model.h"
 
 /* global "model" object */
 #include "model.h"
diff --git a/main.cc b/main.cc
index 2a4119a6acb940e615f1342eb715732c13427357..bff111f09dc28a99eff0ff2b70b4526141f39737 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -6,7 +6,7 @@
 
 #include "libthreads.h"
 #include "common.h"
 
 #include "libthreads.h"
 #include "common.h"
-#include "threads.h"
+#include "threads-model.h"
 
 #include "datarace.h"
 
 
 #include "datarace.h"
 
index ee3ce992cef8aa816fde0466ce67b42e5f6161c5..5753c5c4e016e2a6b7433aeee60706e777505860 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -12,7 +12,7 @@
 #include "promise.h"
 #include "datarace.h"
 #include "mutex.h"
 #include "promise.h"
 #include "datarace.h"
 #include "mutex.h"
-#include "threads.h"
+#include "threads-model.h"
 
 #define INITIAL_THREAD_ID      0
 
 
 #define INITIAL_THREAD_ID      0
 
index 6ef297a594d6b897110e7663c1f3753f859e0c3a..ce747351d09d328708d5410874f77eb40725df1e 100644 (file)
--- a/mutex.cc
+++ b/mutex.cc
@@ -1,6 +1,6 @@
 #include "mutex.h"
 #include "model.h"
 #include "mutex.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 #include "clockvector.h"
 
 namespace std {
 #include "clockvector.h"
 
 namespace std {
index 3db80e8f6b4f8931ad3a238215c4294c86cd9708..167d6940d37eb20bbac1ad3ccf441661d1a9ed6f 100644 (file)
@@ -4,7 +4,7 @@
 #include "action.h"
 #include "common.h"
 #include "model.h"
 #include "action.h"
 #include "common.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /**
  * @brief Node constructor
 
 /**
  * @brief Node constructor
index 2ce3e297305125baa0a057da571cf266965b916e..ce84ede68b0e58e4c76c280cb6632bc85d76cb02 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -8,7 +8,7 @@
 #define __PROMISE_H__
 
 #include <inttypes.h>
 #define __PROMISE_H__
 
 #include <inttypes.h>
-#include "threads.h"
+#include "threads-model.h"
 
 #include "model.h"
 
 
 #include "model.h"
 
index ec49a7448de6f34b1fa5acb38aaed83fd55dcfb7..da6d469fdfe81498e9078423a14eb6310a0ad9e3 100644 (file)
@@ -1,7 +1,7 @@
 #include <string.h>
 #include <stdlib.h>
 
 #include <string.h>
 #include <stdlib.h>
 
-#include "threads.h"
+#include "threads-model.h"
 #include "schedule.h"
 #include "common.h"
 #include "model.h"
 #include "schedule.h"
 #include "common.h"
 #include "model.h"
diff --git a/threads-model.h b/threads-model.h
new file mode 100644 (file)
index 0000000..28d237d
--- /dev/null
@@ -0,0 +1,164 @@
+/** @file threads-model.h
+ *  @brief Model Checker Thread class.
+ */
+
+#ifndef __THREADS_MODEL_H__
+#define __THREADS_MODEL_H__
+
+#include <ucontext.h>
+#include <stdint.h>
+#include <vector>
+
+#include "mymemory.h"
+#include "libthreads.h"
+#include "modeltypes.h"
+
+/** @brief Represents the state of a user Thread */
+typedef enum thread_state {
+       /** Thread was just created and hasn't run yet */
+       THREAD_CREATED,
+       /** Thread is running */
+       THREAD_RUNNING,
+       /** Thread is not currently running but is ready to run */
+       THREAD_READY,
+       /**
+        * Thread is waiting on another action (e.g., thread completion, lock
+        * release, etc.)
+        */
+       THREAD_BLOCKED,
+       /** Thread has completed its execution */
+       THREAD_COMPLETED
+} thread_state;
+
+class ModelAction;
+
+/** @brief A Thread is created for each user-space thread */
+class Thread {
+public:
+       Thread(thread_id_t tid);
+       Thread(thrd_t *t, void (*func)(void *), void *a);
+       ~Thread();
+       void complete();
+
+       static int swap(ucontext_t *ctxt, Thread *t);
+       static int swap(Thread *t, ucontext_t *ctxt);
+
+       thread_state get_state() { return state; }
+       void set_state(thread_state s) { state = s; }
+       thread_id_t get_id();
+       thrd_t get_thrd_t() { return *user_thread; }
+       Thread * get_parent() { return parent; }
+
+       void set_creation(ModelAction *act) { creation = act; }
+       ModelAction * get_creation() { return creation; }
+
+       /**
+        * Set a return value for the last action in this thread (e.g., for an
+        * atomic read).
+        * @param value The value to return
+        */
+       void set_return_value(uint64_t value) { last_action_val = value; }
+
+       /**
+        * Retrieve a return value for the last action in this thread. Used,
+        * for instance, for an atomic read to return the 'read' value. Should
+        * be called from a user context.
+        * @return The value 'returned' by the action
+        */
+       uint64_t get_return_value() { return last_action_val; }
+
+       /** @return True if this thread is finished executing */
+       bool is_complete() { return state == THREAD_COMPLETED; }
+
+       /** @return True if this thread is blocked */
+       bool is_blocked() { return state == THREAD_BLOCKED; }
+
+       /** @return True if no threads are waiting on this Thread */
+       bool wait_list_empty() { return wait_list.empty(); }
+
+       /**
+        * Add a ModelAction to the waiting list for this thread.
+        * @param t The ModelAction to add. Must be a JOIN.
+        */
+       void push_wait_list(ModelAction *act) { wait_list.push_back(act); }
+
+       unsigned int num_wait_list() {
+               return wait_list.size();
+       }
+
+       ModelAction * get_waiter(unsigned int i) {
+               return wait_list[i];
+       }
+
+       ModelAction * get_pending() { return pending; }
+       void set_pending(ModelAction *act) { pending = act; }
+       /**
+        * Remove one ModelAction from the waiting list
+        * @return The ModelAction that was removed from the waiting list
+        */
+       ModelAction * pop_wait_list() {
+               ModelAction *ret = wait_list.front();
+               wait_list.pop_back();
+               return ret;
+       }
+
+       bool is_model_thread() { return model_thread; }
+
+       friend void thread_startup();
+
+       /**
+        * Intentionally NOT allocated with MODELALLOC or SNAPSHOTALLOC.
+        * Threads should be allocated on the user's normal (snapshotting) heap
+        * to allow their allocation/deallocation to follow the same pattern as
+        * the rest of the backtracked/replayed program.
+        */
+private:
+       int create_context();
+       Thread *parent;
+       ModelAction *creation;
+
+       ModelAction *pending;
+       void (*start_routine)(void *);
+       void *arg;
+       ucontext_t context;
+       void *stack;
+       thrd_t *user_thread;
+       thread_id_t id;
+       thread_state state;
+
+       /**
+        * A list of ModelActions waiting on this Thread. Particularly, this
+        * list is used for thread joins, where another Thread waits for this
+        * Thread to complete
+        */
+       std::vector< ModelAction *, SnapshotAlloc<ModelAction *> > wait_list;
+
+       /**
+        * The value returned by the last action in this thread
+        * @see Thread::set_return_value()
+        * @see Thread::get_return_value()
+        */
+       uint64_t last_action_val;
+
+       /** @brief Is this Thread a special model-checker thread? */
+       const bool model_thread;
+};
+
+Thread * thread_current();
+
+static inline thread_id_t thrd_to_id(thrd_t t)
+{
+       return t;
+}
+
+static inline thread_id_t int_to_id(int i)
+{
+       return i;
+}
+
+static inline int id_to_int(thread_id_t id)
+{
+       return id;
+}
+
+#endif /* __THREADS_MODEL_H__ */
index 7f515159f78052727180b1be6d82ba1df7e9ebac..2ff058f45ebe727e952b2769a9f2336dc461106b 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "libthreads.h"
 #include "common.h"
 
 #include "libthreads.h"
 #include "common.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /* global "model" object */
 #include "model.h"
 
 /* global "model" object */
 #include "model.h"
diff --git a/threads.h b/threads.h
deleted file mode 100644 (file)
index 91db236..0000000
--- a/threads.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/** @file threads.h
- *  @brief Model Checker Thread class.
- */
-
-#ifndef __THREADS_H__
-#define __THREADS_H__
-
-#include <ucontext.h>
-#include <stdint.h>
-#include <vector>
-
-#include "mymemory.h"
-#include "libthreads.h"
-#include "modeltypes.h"
-
-/** @brief Represents the state of a user Thread */
-typedef enum thread_state {
-       /** Thread was just created and hasn't run yet */
-       THREAD_CREATED,
-       /** Thread is running */
-       THREAD_RUNNING,
-       /** Thread is not currently running but is ready to run */
-       THREAD_READY,
-       /**
-        * Thread is waiting on another action (e.g., thread completion, lock
-        * release, etc.)
-        */
-       THREAD_BLOCKED,
-       /** Thread has completed its execution */
-       THREAD_COMPLETED
-} thread_state;
-
-class ModelAction;
-
-/** @brief A Thread is created for each user-space thread */
-class Thread {
-public:
-       Thread(thread_id_t tid);
-       Thread(thrd_t *t, void (*func)(void *), void *a);
-       ~Thread();
-       void complete();
-
-       static int swap(ucontext_t *ctxt, Thread *t);
-       static int swap(Thread *t, ucontext_t *ctxt);
-
-       thread_state get_state() { return state; }
-       void set_state(thread_state s) { state = s; }
-       thread_id_t get_id();
-       thrd_t get_thrd_t() { return *user_thread; }
-       Thread * get_parent() { return parent; }
-
-       void set_creation(ModelAction *act) { creation = act; }
-       ModelAction * get_creation() { return creation; }
-
-       /**
-        * Set a return value for the last action in this thread (e.g., for an
-        * atomic read).
-        * @param value The value to return
-        */
-       void set_return_value(uint64_t value) { last_action_val = value; }
-
-       /**
-        * Retrieve a return value for the last action in this thread. Used,
-        * for instance, for an atomic read to return the 'read' value. Should
-        * be called from a user context.
-        * @return The value 'returned' by the action
-        */
-       uint64_t get_return_value() { return last_action_val; }
-
-       /** @return True if this thread is finished executing */
-       bool is_complete() { return state == THREAD_COMPLETED; }
-
-       /** @return True if this thread is blocked */
-       bool is_blocked() { return state == THREAD_BLOCKED; }
-
-       /** @return True if no threads are waiting on this Thread */
-       bool wait_list_empty() { return wait_list.empty(); }
-
-       /**
-        * Add a ModelAction to the waiting list for this thread.
-        * @param t The ModelAction to add. Must be a JOIN.
-        */
-       void push_wait_list(ModelAction *act) { wait_list.push_back(act); }
-
-       unsigned int num_wait_list() {
-               return wait_list.size();
-       }
-
-       ModelAction * get_waiter(unsigned int i) {
-               return wait_list[i];
-       }
-
-       ModelAction * get_pending() { return pending; }
-       void set_pending(ModelAction *act) { pending = act; }
-       /**
-        * Remove one ModelAction from the waiting list
-        * @return The ModelAction that was removed from the waiting list
-        */
-       ModelAction * pop_wait_list() {
-               ModelAction *ret = wait_list.front();
-               wait_list.pop_back();
-               return ret;
-       }
-
-       bool is_model_thread() { return model_thread; }
-
-       friend void thread_startup();
-
-       /**
-        * Intentionally NOT allocated with MODELALLOC or SNAPSHOTALLOC.
-        * Threads should be allocated on the user's normal (snapshotting) heap
-        * to allow their allocation/deallocation to follow the same pattern as
-        * the rest of the backtracked/replayed program.
-        */
-private:
-       int create_context();
-       Thread *parent;
-       ModelAction *creation;
-
-       ModelAction *pending;
-       void (*start_routine)(void *);
-       void *arg;
-       ucontext_t context;
-       void *stack;
-       thrd_t *user_thread;
-       thread_id_t id;
-       thread_state state;
-
-       /**
-        * A list of ModelActions waiting on this Thread. Particularly, this
-        * list is used for thread joins, where another Thread waits for this
-        * Thread to complete
-        */
-       std::vector< ModelAction *, SnapshotAlloc<ModelAction *> > wait_list;
-
-       /**
-        * The value returned by the last action in this thread
-        * @see Thread::set_return_value()
-        * @see Thread::get_return_value()
-        */
-       uint64_t last_action_val;
-
-       /** @brief Is this Thread a special model-checker thread? */
-       const bool model_thread;
-};
-
-Thread * thread_current();
-
-static inline thread_id_t thrd_to_id(thrd_t t)
-{
-       return t;
-}
-
-static inline thread_id_t int_to_id(int i)
-{
-       return i;
-}
-
-static inline int id_to_int(thread_id_t id)
-{
-       return id;
-}
-
-#endif /* __THREADS_H__ */