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
14typedef struct _thread _thread_t;
15
16typedef 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
23typedef struct _thread
24{
26 atomic_uint64_t state;
28 int result;
30 void* private;
31} _thread_t;
32
33void _threading_init(void);
34
35_thread_t* _thread_new(_thread_entry_t entry, void* private);
36
37void _thread_free(_thread_t* thread);
38
int errno_t
Definition errno_t.h:4
__UINT64_TYPE__ tid_t
Thread Identifier.
Definition tid_t.h:12
void _threading_init(void)
Definition thread.c:21
_thread_t * _thread_get(tid_t id)
Definition thread.c:72
void(* _thread_entry_t)(_thread_t *)
Definition thread.h:16
_thread_t * _thread_new(_thread_entry_t entry, void *private)
Definition thread.c:33
void _thread_free(_thread_t *thread)
Definition thread.c:61
tid_t id
Definition thread.h:27
int result
Definition thread.h:28
list_entry_t entry
Definition thread.h:25
errno_t err
Definition thread.h:29
atomic_uint64_t state
Definition thread.h:26
A entry in a doubly linked list.
Definition list.h:38