+#include <stdio.h>
+
#include "model.h"
#include "schedule.h"
{
this->system_thread = t;
}
+
+ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value)
+{
+ struct thread *t = thread_current();
+ ModelAction *act = this;
+
+ act->type = type;
+ act->order = order;
+ act->location = loc;
+ act->tid = t->id;
+ act->value = value;
+}
+
+void ModelAction::print(void)
+{
+ const char *type_str;
+ switch (this->type) {
+ case THREAD_CREATE:
+ type_str = "thread create";
+ break;
+ case THREAD_YIELD:
+ type_str = "thread yield";
+ break;
+ case THREAD_JOIN:
+ type_str = "thread join";
+ break;
+ case ATOMIC_READ:
+ type_str = "atomic read";
+ break;
+ case ATOMIC_WRITE:
+ type_str = "atomic write";
+ break;
+ default:
+ type_str = "unknown type";
+ }
+
+ printf("Thread: %d\tAction: %s\tMO: %d\tLoc: %#014zx\tValue: %d\n", tid, type_str, order, (size_t)location, value);
+}
#define __MODEL_H__
#include "schedule.h"
+#include "libthreads.h"
+#include "libatomic.h"
+
+#define VALUE_NONE -1
+
+typedef enum action_type {
+ THREAD_CREATE,
+ THREAD_YIELD,
+ THREAD_JOIN,
+ ATOMIC_READ,
+ ATOMIC_WRITE
+} action_type_t;
+
+class ModelAction {
+public:
+ ModelAction(action_type_t type, memory_order order, void *loc, int value);
+ void print(void);
+private:
+ action_type type;
+ memory_order order;
+ void *location;
+ thread_id_t tid;
+ int value;
+};
class ModelChecker {
public: