PatchworkOS
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
errno.h
>
4
#include <
stdatomic.h
>
5
#include <
stdbool.h
>
6
#include <
sys/list.h
>
7
#include <
sys/proc.h
>
8
#include <
threads.h
>
9
10
#define _MTX_SPIN_COUNT 100
11
12
#define _THREAD_ENTRY_ATTRIBUTES __attribute__((noreturn)) __attribute__((force_align_arg_pointer))
13
14
typedef
struct
_thread
_thread_t
;
15
16
typedef
void (*
_thread_entry_t
)(
_thread_t
*);
17
18
#define _THREAD_ATTACHED 1
19
#define _THREAD_DETACHED 2
20
#define _THREAD_JOINING 3
21
#define _THREAD_EXITED 4
22
23
typedef
struct
_thread
24
{
25
list_entry_t
entry
;
26
atomic_uint64_t
state
;
27
tid_t
id
;
28
int
result
;
29
errno_t
err
;
30
void
*
private
;
31
}
_thread_t
;
32
33
void
_threading_init
(
void
);
34
35
_thread_t
*
_thread_new
(
_thread_entry_t
entry,
void
*
private
);
36
37
void
_thread_free
(
_thread_t
* thread);
38
39
_thread_t
*
_thread_get
(
tid_t
id
);
errno.h
errno_t
int errno_t
Definition
errno_t.h:4
tid_t
__UINT64_TYPE__ tid_t
Thread Identifier.
Definition
tid_t.h:12
list.h
proc.h
_threading_init
void _threading_init(void)
Definition
thread.c:21
_thread_get
_thread_t * _thread_get(tid_t id)
Definition
thread.c:72
_thread_entry_t
void(* _thread_entry_t)(_thread_t *)
Definition
thread.h:16
_thread_new
_thread_t * _thread_new(_thread_entry_t entry, void *private)
Definition
thread.c:33
_thread_free
void _thread_free(_thread_t *thread)
Definition
thread.c:61
stdatomic.h
stdbool.h
_thread_t
Definition
thread.h:24
_thread_t::id
tid_t id
Definition
thread.h:27
_thread_t::result
int result
Definition
thread.h:28
_thread_t::entry
list_entry_t entry
Definition
thread.h:25
_thread_t::err
errno_t err
Definition
thread.h:29
_thread_t::state
atomic_uint64_t state
Definition
thread.h:26
list_entry_t
A entry in a doubly linked list.
Definition
list.h:38
threads.h
src
libstd
user
common
thread.h
Generated by
1.9.8