-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgtthread.h
55 lines (41 loc) · 1.17 KB
/
gtthread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef GTTHREAD_H
#define GTTHREAD_H
#include "steque.h"
#include <ucontext.h>
/* Define gtthread_t and gtthread_mutex_t types here */
typedef enum threadstate_t {
Ready,
Blocked,
Terminated
} threadstate_t;
typedef unsigned long int gtthread_t;
typedef struct gtthread {
gtthread_t tid;
ucontext_t context;
threadstate_t state;
steque_t* waitthreadlist;
void* retval;
} gtthread;
typedef struct gtthread_mutex_t {
int mutexid;
} gtthread_mutex_t;
typedef struct gtthread_mutex_node
{
gtthread_mutex_t *mutex;
gtthread *holder;
} gtthread_mutex_node;
void gtthread_init(long period);
int gtthread_create(gtthread_t *thread,
void *(*start_routine)(void *),
void *arg);
int gtthread_join(gtthread_t thread, void **status);
void gtthread_exit(void *retval);
void gtthread_yield(void);
int gtthread_equal(gtthread_t t1, gtthread_t t2);
int gtthread_cancel(gtthread_t thread);
gtthread_t gtthread_self(void);
int gtthread_mutex_init(gtthread_mutex_t *mutex);
int gtthread_mutex_lock(gtthread_mutex_t *mutex);
int gtthread_mutex_unlock(gtthread_mutex_t *mutex);
int gtthread_mutex_destroy(gtthread_mutex_t *mutex);
#endif