#include "libatomic.h"
+#include "model.h"
#include "threads_internal.h"
void atomic_store_explicit(struct atomic_object *obj, int value, memory_order order)
{
- thread_switch_to_master();
+ thread_switch_to_master(new ModelAction(ATOMIC_WRITE, order, obj, value));
}
int atomic_load_explicit(struct atomic_object *obj, memory_order order)
{
- thread_switch_to_master();
+ thread_switch_to_master(new ModelAction(ATOMIC_READ, order, obj, VALUE_NONE));
return 0;
}
while (!thread_system_next());
}
-int thread_switch_to_master()
+int thread_switch_to_master(ModelAction *act)
{
struct thread *old, *next;
DBG();
+ model->set_current_action(act);
old = thread_current();
old->state = THREAD_READY;
next = model->system_thread;
{
int ret = 0;
while (t->state != THREAD_COMPLETED && !ret)
- ret = thread_switch_to_master();
+ /* seq_cst is just a 'don't care' parameter */
+ ret = thread_switch_to_master(new ModelAction(THREAD_JOIN, memory_order_seq_cst, NULL, VALUE_NONE));
}
int thread_yield(void)
{
- return thread_switch_to_master();
+ /* seq_cst is just a 'don't care' parameter */
+ return thread_switch_to_master(new ModelAction(THREAD_YIELD, memory_order_seq_cst, NULL, VALUE_NONE));
}
struct thread *thread_current(void)
this->used_thread_id = 0;
/* Initialize default scheduler */
this->scheduler = new DefaultScheduler();
+
+ this->current_action = NULL;
}
ModelChecker::~ModelChecker()
void add_system_thread(struct thread *t);
void assign_id(struct thread *t);
+ void set_current_action(ModelAction *act) { current_action = act; }
+
private:
int used_thread_id;
+ class ModelAction *current_action;
};
extern ModelChecker *model;
#ifndef __THREADS_INTERNAL_H__
#define __THREADS_INTERNAL_H__
+#include "model.h"
#include "libthreads.h"
-int thread_switch_to_master();
+int thread_switch_to_master(ModelAction *act);
#endif /* __THREADS_INTERNAL_H__ */