PatchworkOS  966e257
A non-POSIX operating system.
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/proc.h>
7#include <threads.h>
8
9#define _MTX_SPIN_COUNT 100
10
11#define _THREADS_MAX 2048
12
13typedef struct _thread _thread_t;
14
15typedef void (*_thread_entry_t)(_thread_t*);
16
17#define _THREAD_ATTACHED 1
18#define _THREAD_DETACHED 2
19#define _THREAD_JOINING 3
20#define _THREAD_EXITED 4
21
22typedef struct _thread
23{
24 atomic_uint64_t state;
26 int result;
29 void* arg;
30} _thread_t;
31
32void _threading_init(void);
33
34_thread_t* _thread_new(thrd_start_t func, void* arg);
35
36void _thread_free(_thread_t* thread);
37
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:62
_thread_t * _thread_new(thrd_start_t func, void *arg)
Definition thread.c:85
_thread_t * _thread_get(tid_t id)
Definition thread.c:129
void(* _thread_entry_t)(_thread_t *)
Definition thread.h:15
void _thread_free(_thread_t *thread)
Definition thread.c:120
tid_t id
Definition thread.h:25
int result
Definition thread.h:26
errno_t err
Definition thread.h:27
atomic_uint64_t state
Definition thread.h:24
thrd_start_t func
Definition thread.h:28
void * arg
Definition thread.h:29
int(* thrd_start_t)(void *)
Definition threads.h:60