#include "action.h"
#include "clockvector.h"
#include "common.h"
+#include "threads.h"
#define ACTION_INITIAL_CLOCK 0
#include <list>
#include <cstddef>
+#include <inttypes.h>
-#include "threads.h"
#include "mymemory.h"
-#include "clockvector.h"
#include "memoryorder.h"
+#include "modeltypes.h"
+
+class ClockVector;
using std::memory_order;
using std::memory_order_relaxed;
#include "action.h"
#include "clockvector.h"
#include "common.h"
+#include "threads.h"
/**
* Constructs a new ClockVector, given a parent ClockVector and a first
#ifndef __CLOCKVECTOR_H__
#define __CLOCKVECTOR_H__
-#include "threads.h"
#include "mymemory.h"
+#include "modeltypes.h"
-typedef unsigned int modelclock_t;
/* Forward declaration */
class ModelAction;
#include "model.h"
#include "cmodelint.h"
+#include "threads.h"
/** Performs a read action.*/
uint64_t model_read_action(void * obj, memory_order ord) {
#include <stdio.h>
#include <cstring>
#include "mymemory.h"
+#include "clockvector.h"
struct ShadowTable *root;
std::vector<struct DataRace *> unrealizedraces;
#ifndef DATARACE_H
#include "config.h"
#include <stdint.h>
-#include "clockvector.h"
#include <vector>
+#include "modeltypes.h"
+
+/* Forward declaration */
+class ClockVector;
+class ModelAction;
struct ShadowTable {
void * array[65536];
#include "impatomic.h"
#include "common.h"
#include "model.h"
+#include "threads.h"
namespace std {
#include "common.h"
#include "datarace.h"
#include "model.h"
+#include "threads.h"
void store_8(void *addr, uint8_t val)
{
#include "promise.h"
#include "datarace.h"
#include "mutex.h"
+#include "threads.h"
#define INITIAL_THREAD_ID 0
return priv->next_thread_id;
}
+/** @return The currently executing Thread. */
+Thread * ModelChecker::get_current_thread()
+{
+ return scheduler->get_current_thread();
+}
+
/** @return a sequence number for a new ModelAction */
modelclock_t ModelChecker::get_next_seq_num()
{
scheduler->remove_thread(t);
}
+/**
+ * @brief Get a Thread reference by its ID
+ * @param tid The Thread's ID
+ * @return A Thread reference
+ */
+Thread * ModelChecker::get_thread(thread_id_t tid)
+{
+ return thread_map->get(id_to_int(tid));
+}
+
+/**
+ * @brief Get a reference to the Thread in which a ModelAction was executed
+ * @param act The ModelAction
+ * @return A Thread reference
+ */
+Thread * ModelChecker::get_thread(ModelAction *act)
+{
+ return get_thread(act->get_tid());
+}
+
/**
* Switch from a user-context to the "master thread" context (a.k.a. system
* context). This switch is made with the intention of exploring a particular
* model-checking action (described by a ModelAction object). Must be called
* from a user-thread context.
- * @param act The current action that will be explored. Must not be NULL.
+ *
+ * @param act The current action that will be explored. May be NULL only if
+ * trace is exiting via an assertion (see ModelChecker::set_assert and
+ * ModelChecker::has_asserted).
* @return Return status from the 'swap' call (i.e., success/fail, 0/-1)
*/
int ModelChecker::switch_to_master(ModelAction *act)
#include <cstddef>
#include <ucontext.h>
-#include "schedule.h"
#include "mymemory.h"
-#include "libthreads.h"
-#include "threads.h"
#include "action.h"
-#include "clockvector.h"
#include "hashtable.h"
#include "workqueue.h"
#include "config.h"
+#include "modeltypes.h"
/* Forward declaration */
class NodeStack;
class CycleGraph;
class Promise;
+class Scheduler;
+class Thread;
/** @brief Shorthand for a list of release sequence heads */
typedef std::vector< const ModelAction *, ModelAlloc<const ModelAction *> > rel_heads_list_t;
void add_thread(Thread *t);
void remove_thread(Thread *t);
- Thread * get_thread(thread_id_t tid) { return thread_map->get(id_to_int(tid)); }
- Thread * get_thread(ModelAction *act) { return get_thread(act->get_tid()); }
+ Thread * get_thread(thread_id_t tid);
+ Thread * get_thread(ModelAction *act);
thread_id_t get_next_id();
int get_num_threads();
-
- /** @return The currently executing Thread. */
- Thread * get_current_thread() { return scheduler->get_current_thread(); }
+ Thread * get_current_thread();
int switch_to_master(ModelAction *act);
ClockVector * get_cv(thread_id_t tid);
--- /dev/null
+#ifndef __MODELTYPES_H__
+#define __MODELTYPES_H__
+
+typedef int thread_id_t;
+
+#define THREAD_ID_T_NONE -1
+
+typedef unsigned int modelclock_t;
+
+#endif /* __MODELTYPES_H__ */
#include "mutex.h"
#include "model.h"
+#include "threads.h"
+#include "clockvector.h"
namespace std {
mutex::mutex() {
#ifndef MUTEX_H
#define MUTEX_H
-#include "threads.h"
-#include "clockvector.h"
+
+#include "modeltypes.h"
namespace std {
struct mutex_state {
#include "action.h"
#include "common.h"
#include "model.h"
+#include "threads.h"
/**
* @brief Node constructor
return thread_id < num_threads && enabled_array[thread_id];
}
+bool Node::has_priority(thread_id_t tid)
+{
+ return fairness[id_to_int(tid)].priority;
+}
+
/**
* Add an action to the may_read_from set.
* @param act is the action to add
#include <list>
#include <vector>
#include <cstddef>
-#include "threads.h"
+#include <inttypes.h>
+
#include "mymemory.h"
-#include "clockvector.h"
+#include "modeltypes.h"
class ModelAction;
+class Thread;
/**
* A flag used for the promise counting/combination problem within a node,
bool is_enabled(Thread *t);
bool is_enabled(thread_id_t tid);
ModelAction * get_action() { return action; }
- bool has_priority(thread_id_t tid) {return fairness[id_to_int(tid)].priority;}
+ bool has_priority(thread_id_t tid);
int get_num_threads() {return num_threads;}
/** @return the parent Node to this Node; that is, the action that
* occurred previously in the stack. */
#include "mymemory.h"
#include "libthreads.h"
-
-typedef int thread_id_t;
-
-#define THREAD_ID_T_NONE -1
+#include "modeltypes.h"
/** @brief Represents the state of a user Thread */
typedef enum thread_state {