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