X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=libthreads.cc;h=a414686dccb713116bad22a1e6126f590b72cc7b;hp=a43505e0e7d4fa18fda72f1d455532414c67f372;hb=f48c73aeda479368d4bfaf96fe9fe07f3d3d8bdb;hpb=517d8ce6cc880bb523ee55005afdcad1ec551e64 diff --git a/libthreads.cc b/libthreads.cc index a43505e0..a414686d 100644 --- a/libthreads.cc +++ b/libthreads.cc @@ -8,12 +8,16 @@ /* * User program API functions */ -int thrd_create(thrd_t *t, void (*start_routine)(), void *arg) +int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg) { + Thread *thread; int ret; DBG(); - ret = model->add_thread(new Thread(t, start_routine, arg)); - DEBUG("create thread %d\n", thrd_to_id(*t)); + thread = new Thread(t, start_routine, arg); + ret = model->add_thread(thread); + DEBUG("create thread %d\n", id_to_int(thrd_to_id(*t))); + /* seq_cst is just a 'don't care' parameter */ + model->switch_to_master(new ModelAction(THREAD_CREATE, memory_order_seq_cst, thread, VALUE_NONE)); return ret; } @@ -22,8 +26,7 @@ int thrd_join(thrd_t t) int ret = 0; Thread *th = model->get_thread(thrd_to_id(t)); while (th->get_state() != THREAD_COMPLETED && !ret) - /* seq_cst is just a 'don't care' parameter */ - ret = model->switch_to_master(new ModelAction(THREAD_JOIN, memory_order_seq_cst, NULL, VALUE_NONE)); + ret = model->switch_to_master(NULL); return ret; }