Fix yield bug part 2
[satcheck.git] / libthreads.cc
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
5  *      This program is free software; you can redistribute it and/or
6  *      modify it under the terms of the GNU General Public License
7  *      version 2 as published by the Free Software Foundation.
8  */
9
10 #include <threads.h>
11 #include "common.h"
12 #include "threads-model.h"
13
14 /* global "model" object */
15 #include "model.h"
16
17 /*
18  * User program API functions
19  */
20 int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg)
21 {
22         model->get_execution()->threadCreate(t, start_routine, arg);
23         return 0;
24 }
25
26 int thrd_join(thrd_t t)
27 {
28         Thread *th = t.priv;
29         model->get_execution()->threadJoin(th);
30         return 0;
31 }
32
33 void thrd_yield(void)
34 {
35         model->get_execution()->threadYield();
36 }
37
38 thrd_t thrd_current(void)
39 {
40         return thread_current()->get_thrd_t();
41 }