projects
/
c11tester.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
model: add build_reads_from_past() function
[c11tester.git]
/
threads.h
diff --git
a/threads.h
b/threads.h
index b973224d7a3d1e436de2d1b7dc20673b813916b6..a97a04c704449963981fe443a711c64abc716fb3 100644
(file)
--- a/
threads.h
+++ b/
threads.h
@@
-1,10
+1,18
@@
+/** @file threads.h
+ * @brief Model Checker Thread class.
+ */
+
#ifndef __THREADS_H__
#define __THREADS_H__
#include <ucontext.h>
#ifndef __THREADS_H__
#define __THREADS_H__
#include <ucontext.h>
-
+#include "mymemory.h"
#include "libthreads.h"
#include "libthreads.h"
+typedef int thread_id_t;
+
+#define THREAD_ID_T_NONE -1
+
typedef enum thread_state {
THREAD_CREATED,
THREAD_RUNNING,
typedef enum thread_state {
THREAD_CREATED,
THREAD_RUNNING,
@@
-12,34
+20,59
@@
typedef enum thread_state {
THREAD_COMPLETED
} thread_state;
THREAD_COMPLETED
} thread_state;
+class ModelAction;
+
+/** @brief A Thread is created for each user-space thread */
class Thread {
public:
class Thread {
public:
- Thread(thrd_t *t, void (*func)(), void *a);
- Thread(thrd_t *t);
- int swap(Thread *t);
- void dispose();
+ 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();
thread_state get_state() { return state; }
void set_state(thread_state s) { state = s; }
thread_id_t get_id();
- void set_id(thread_id_t i) { *user_thread = i; }
thrd_t get_thrd_t() { return *user_thread; }
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; }
+
+ friend void thread_startup();
+
+ SNAPSHOTALLOC
private:
int create_context();
private:
int create_context();
+ Thread *parent;
+ ModelAction *creation;
- void (*start_routine)();
+ void (*start_routine)(
void *
);
void *arg;
ucontext_t context;
void *stack;
thrd_t *user_thread;
void *arg;
ucontext_t context;
void *stack;
thrd_t *user_thread;
+ thread_id_t id;
thread_state state;
};
thread_state state;
};
-Thread *thread_current();
+Thread *
thread_current();
static inline thread_id_t thrd_to_id(thrd_t t)
{
return t;
}
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__ */
#endif /* __THREADS_H__ */