PatchworkOS
Loading...
Searching...
No Matches
thread.h File Reference
#include <errno.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <sys/list.h>
#include <sys/proc.h>
#include <threads.h>

Go to the source code of this file.

Data Structures

struct  _thread_t
 

Macros

#define _MTX_SPIN_COUNT   100
 
#define _THREAD_ENTRY_ATTRIBUTES   __attribute__((noreturn)) __attribute__((force_align_arg_pointer))
 
#define _THREAD_ATTACHED   1
 
#define _THREAD_DETACHED   2
 
#define _THREAD_JOINING   3
 
#define _THREAD_EXITED   4
 

Typedefs

typedef struct _thread _thread_t
 
typedef void(* _thread_entry_t) (_thread_t *)
 

Functions

void _threading_init (void)
 
_thread_t_thread_new (_thread_entry_t entry, void *private)
 
void _thread_free (_thread_t *thread)
 
_thread_t_thread_get (tid_t id)
 

Macro Definition Documentation

◆ _MTX_SPIN_COUNT

#define _MTX_SPIN_COUNT   100

Definition at line 10 of file thread.h.

◆ _THREAD_ATTACHED

#define _THREAD_ATTACHED   1

Definition at line 18 of file thread.h.

◆ _THREAD_DETACHED

#define _THREAD_DETACHED   2

Definition at line 19 of file thread.h.

◆ _THREAD_ENTRY_ATTRIBUTES

#define _THREAD_ENTRY_ATTRIBUTES   __attribute__((noreturn)) __attribute__((force_align_arg_pointer))

Definition at line 12 of file thread.h.

◆ _THREAD_EXITED

#define _THREAD_EXITED   4

Definition at line 21 of file thread.h.

◆ _THREAD_JOINING

#define _THREAD_JOINING   3

Definition at line 20 of file thread.h.

Typedef Documentation

◆ _thread_entry_t

typedef void(* _thread_entry_t) (_thread_t *)

Definition at line 16 of file thread.h.

◆ _thread_t

typedef struct _thread _thread_t

Definition at line 14 of file thread.h.

Function Documentation

◆ _thread_free()

void _thread_free ( _thread_t thread)

Definition at line 61 of file thread.c.

References _thread_t::entry, free(), list_remove(), mtx_lock(), mtx_unlock(), mutex, thread0, and threads.

Referenced by thrd_exit(), and thrd_join().

◆ _thread_get()

_thread_t * _thread_get ( tid_t  id)

Definition at line 72 of file thread.c.

References _thread_t::id, LIST_FOR_EACH, mtx_lock(), mtx_unlock(), mutex, NULL, and threads.

Referenced by _errno_get(), thrd_detach(), thrd_exit(), and thrd_join().

◆ _thread_new()

◆ _threading_init()

void _threading_init ( void  )