1 #include "libthreads.h"
5 /* global "model" object */
9 * User program API functions
11 int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg)
16 thread = new Thread(t, start_routine, arg);
17 ret = model->add_thread(thread);
18 DEBUG("create thread %d\n", id_to_int(thrd_to_id(*t)));
19 /* seq_cst is just a 'don't care' parameter */
20 model->switch_to_master(new ModelAction(THREAD_CREATE, std::memory_order_seq_cst, thread, VALUE_NONE));
24 int thrd_join(thrd_t t)
26 Thread *th = model->get_thread(thrd_to_id(t));
27 while (th->get_state() != THREAD_COMPLETED)
28 model->switch_to_master(NULL);
34 /* seq_cst is just a 'don't care' parameter */
35 return model->switch_to_master(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, NULL, VALUE_NONE));
38 thrd_t thrd_current(void)
40 return thread_current()->get_thrd_t();