4 #include <minix/config.h> /* MUST be first */
5 #include <minix/const.h>
13 #include <sys/signal.h>
16 typedef int mthread_thread_t
;
17 typedef int mthread_once_t
;
18 typedef int mthread_key_t
;
19 typedef void * mthread_condattr_t
;
20 typedef void * mthread_mutexattr_t
;
24 struct __mthread_tcb
*mq_head
;
25 struct __mthread_tcb
*mq_tail
;
28 struct __mthread_mutex
{
29 mthread_queue_t mm_queue
; /* Queue of threads blocked on this mutex */
30 mthread_thread_t mm_owner
; /* Thread ID that currently owns mutex */
32 struct __mthread_mutex
*mm_prev
;
33 struct __mthread_mutex
*mm_next
;
35 unsigned int mm_magic
;
37 typedef struct __mthread_mutex
*mthread_mutex_t
;
39 struct __mthread_cond
{
40 struct __mthread_mutex
*mc_mutex
; /* Associate mutex with condition */
42 struct __mthread_cond
*mc_prev
;
43 struct __mthread_cond
*mc_next
;
45 unsigned int mc_magic
;
47 typedef struct __mthread_cond
*mthread_cond_t
;
49 struct __mthread_attr
{
53 struct __mthread_attr
*ma_prev
;
54 struct __mthread_attr
*ma_next
;
56 typedef struct __mthread_attr
*mthread_attr_t
;
59 mthread_mutex_t mutex
;
65 mthread_thread_t writer
;
66 mthread_mutex_t queue
;
67 mthread_event_t drain
;
70 #define MTHREAD_CREATE_JOINABLE 001
71 #define MTHREAD_CREATE_DETACHED 002
72 #define MTHREAD_ONCE_INIT 0
73 #define MTHREAD_STACK_MIN MINSIGSTKSZ
74 #define MTHREAD_KEYS_MAX 128
77 int mthread_create(mthread_thread_t
*thread
, mthread_attr_t
*tattr
, void
78 *(*proc
)(void *), void *arg
);
79 int mthread_detach(mthread_thread_t thread
);
80 int mthread_equal(mthread_thread_t l
, mthread_thread_t r
);
81 void mthread_exit(void *value
);
82 int mthread_join(mthread_thread_t thread
, void **value
);
83 int mthread_once(mthread_once_t
*once
, void (*proc
)(void));
84 mthread_thread_t
mthread_self(void);
87 int mthread_attr_destroy(mthread_attr_t
*tattr
);
88 int mthread_attr_getdetachstate(mthread_attr_t
*tattr
, int
90 int mthread_attr_getstack(mthread_attr_t
*tattr
, void **stackaddr
,
92 int mthread_attr_getstacksize(mthread_attr_t
*tattr
, size_t *stacksize
);
93 int mthread_attr_init(mthread_attr_t
*tattr
);
94 int mthread_attr_setdetachstate(mthread_attr_t
*tattr
, int detachstate
);
95 int mthread_attr_setstack(mthread_attr_t
*tattr
, void *stackaddr
, size_t
97 int mthread_attr_setstacksize(mthread_attr_t
*tattr
, size_t stacksize
);
101 int mthread_cond_broadcast(mthread_cond_t
*cond
);
102 int mthread_cond_destroy(mthread_cond_t
*cond
);
103 int mthread_cond_init(mthread_cond_t
*cond
, mthread_condattr_t
*cattr
);
104 int mthread_cond_signal(mthread_cond_t
*cond
);
105 int mthread_cond_wait(mthread_cond_t
*cond
, mthread_mutex_t
*mutex
);
108 int mthread_key_create(mthread_key_t
*key
, void (*destructor
)(void *));
109 int mthread_key_delete(mthread_key_t key
);
110 void *mthread_getspecific(mthread_key_t key
);
111 int mthread_setspecific(mthread_key_t key
, void *value
);
114 void mthread_stats(void);
115 void mthread_verify_f(char *f
, int l
);
116 #define mthread_verify() mthread_verify_f(__FILE__, __LINE__)
117 void mthread_stacktrace(mthread_thread_t t
);
118 void mthread_stacktraces(void);
121 int mthread_mutex_destroy(mthread_mutex_t
*mutex
);
122 int mthread_mutex_init(mthread_mutex_t
*mutex
, mthread_mutexattr_t
124 int mthread_mutex_lock(mthread_mutex_t
*mutex
);
125 int mthread_mutex_trylock(mthread_mutex_t
*mutex
);
126 int mthread_mutex_unlock(mthread_mutex_t
*mutex
);
129 int mthread_event_destroy(mthread_event_t
*event
);
130 int mthread_event_init(mthread_event_t
*event
);
131 int mthread_event_wait(mthread_event_t
*event
);
132 int mthread_event_fire(mthread_event_t
*event
);
133 int mthread_event_fire_all(mthread_event_t
*event
);
136 int mthread_rwlock_destroy(mthread_rwlock_t
*rwlock
);
137 int mthread_rwlock_init(mthread_rwlock_t
*rwlock
);
138 int mthread_rwlock_rdlock(mthread_rwlock_t
*rwlock
);
139 int mthread_rwlock_wrlock(mthread_rwlock_t
*rwlock
);
140 int mthread_rwlock_unlock(mthread_rwlock_t
*rwlock
);
143 void mthread_init(void);
144 int mthread_yield(void);
145 void mthread_yield_all(void);