PatchworkOS
Loading...
Searching...
No Matches
threads.h File Reference
#include <stdatomic.h>
#include "_internal/config.h"
#include "_internal/pid_t.h"
#include "_internal/tid_t.h"
#include "_internal/timespec.h"

Go to the source code of this file.

Data Structures

struct  cnd_t
 
struct  thrd_t
 
struct  tss_t
 Task State Segment structure. More...
 
struct  mtx_t
 

Macros

#define ONCE_FLAG_INIT   0
 
#define TSS_DTOR_ITERATIONS   4
 
#define _MTX_UNLOCKED   0
 
#define _MTX_LOCKED   1
 
#define _MTX_CONTESTED   2
 

Typedefs

typedef void(* tss_dtor_t) (void *)
 
typedef int(* thrd_start_t) (void *)
 
typedef int once_flag
 

Enumerations

enum  {
  mtx_plain ,
  mtx_recursive ,
  mtx_timed
}
 
enum  {
  thrd_timedout ,
  thrd_success ,
  thrd_busy ,
  thrd_error ,
  thrd_nomem
}
 

Functions

_PUBLIC void call_once (once_flag *flag, void(*func)(void))
 
_PUBLIC int cnd_broadcast (cnd_t *cond)
 
_PUBLIC void cnd_destroy (cnd_t *cond)
 
_PUBLIC int cnd_init (cnd_t *cond)
 
_PUBLIC int cnd_signal (cnd_t *cond)
 
_PUBLIC int cnd_timedwait (cnd_t *_RESTRICT cond, mtx_t *_RESTRICT mtx, const struct timespec *_RESTRICT ts)
 
int cnd_wait (cnd_t *cond, mtx_t *mtx)
 
_PUBLIC void mtx_destroy (mtx_t *mtx)
 
_PUBLIC int mtx_init (mtx_t *mtx, int type)
 
_PUBLIC int mtx_lock (mtx_t *mtx)
 
_PUBLIC int mtx_timedlock (mtx_t *_RESTRICT mtx, const struct timespec *_RESTRICT ts)
 
_PUBLIC int mtx_trylock (mtx_t *mtx)
 
_PUBLIC int mtx_unlock (mtx_t *mtx)
 
_PUBLIC int thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
 
_PUBLIC thrd_t thrd_current (void)
 
_PUBLIC int thrd_detach (thrd_t thr)
 
_PUBLIC int thrd_equal (thrd_t thr0, thrd_t thr1)
 
_PUBLIC _NORETURN void thrd_exit (int res)
 
_PUBLIC int thrd_join (thrd_t thr, int *res)
 
_PUBLIC int thrd_sleep (const struct timespec *duration, struct timespec *remaining)
 
_PUBLIC void thrd_yield (void)
 
_PUBLIC int tss_create (tss_t *key, tss_dtor_t dtor)
 
_PUBLIC void tss_delete (tss_t key)
 
_PUBLIC void * tss_get (tss_t key)
 
_PUBLIC int tss_set (tss_t key, void *val)
 

Macro Definition Documentation

◆ _MTX_CONTESTED

#define _MTX_CONTESTED   2

Definition at line 49 of file threads.h.

◆ _MTX_LOCKED

#define _MTX_LOCKED   1

Definition at line 48 of file threads.h.

◆ _MTX_UNLOCKED

#define _MTX_UNLOCKED   0

Definition at line 47 of file threads.h.

◆ ONCE_FLAG_INIT

#define ONCE_FLAG_INIT   0

Definition at line 26 of file threads.h.

◆ TSS_DTOR_ITERATIONS

#define TSS_DTOR_ITERATIONS   4

Definition at line 28 of file threads.h.

Typedef Documentation

◆ once_flag

typedef int once_flag

Definition at line 62 of file threads.h.

◆ thrd_start_t

typedef int(* thrd_start_t) (void *)

Definition at line 60 of file threads.h.

◆ tss_dtor_t

typedef void(* tss_dtor_t) (void *)

Definition at line 58 of file threads.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
mtx_plain 
mtx_recursive 
mtx_timed 

Definition at line 64 of file threads.h.

◆ anonymous enum

anonymous enum
Enumerator
thrd_timedout 
thrd_success 
thrd_busy 
thrd_error 
thrd_nomem 

Definition at line 71 of file threads.h.

Function Documentation

◆ call_once()

_PUBLIC void call_once ( once_flag flag,
void(*)(void)  func 
)

◆ cnd_broadcast()

_PUBLIC int cnd_broadcast ( cnd_t cond)

◆ cnd_destroy()

_PUBLIC void cnd_destroy ( cnd_t cond)

◆ cnd_init()

_PUBLIC int cnd_init ( cnd_t cond)

◆ cnd_signal()

_PUBLIC int cnd_signal ( cnd_t cond)

◆ cnd_timedwait()

_PUBLIC int cnd_timedwait ( cnd_t *_RESTRICT  cond,
mtx_t *_RESTRICT  mtx,
const struct timespec *_RESTRICT  ts 
)

◆ cnd_wait()

int cnd_wait ( cnd_t cond,
mtx_t mtx 
)

◆ mtx_destroy()

_PUBLIC void mtx_destroy ( mtx_t mtx)

Definition at line 10 of file mtx_destroy.c.

References mutex.

Referenced by _file_deinit(), and display_free().

◆ mtx_init()

_PUBLIC int mtx_init ( mtx_t mtx,
int  type 
)

◆ mtx_lock()

◆ mtx_timedlock()

_PUBLIC int mtx_timedlock ( mtx_t *_RESTRICT  mtx,
const struct timespec *_RESTRICT  ts 
)

◆ mtx_trylock()

_PUBLIC int mtx_trylock ( mtx_t mtx)

◆ mtx_unlock()

◆ thrd_create()

_PUBLIC int thrd_create ( thrd_t thr,
thrd_start_t  func,
void *  arg 
)

◆ thrd_current()

_PUBLIC thrd_t thrd_current ( void  )

Definition at line 10 of file thrd_current.c.

References gettid(), and thrd_t::id.

◆ thrd_detach()

◆ thrd_equal()

_PUBLIC int thrd_equal ( thrd_t  thr0,
thrd_t  thr1 
)

Definition at line 10 of file thrd_equal.c.

References thrd_t::id.

◆ thrd_exit()

◆ thrd_join()

◆ thrd_sleep()

_PUBLIC int thrd_sleep ( const struct timespec duration,
struct timespec remaining 
)

◆ thrd_yield()

_PUBLIC void thrd_yield ( void  )

Definition at line 10 of file thrd_yield.c.

References _syscall_yield().

Referenced by start_services().

◆ tss_create()

_PUBLIC int tss_create ( tss_t key,
tss_dtor_t  dtor 
)

◆ tss_delete()

_PUBLIC void tss_delete ( tss_t  key)

◆ tss_get()

_PUBLIC void * tss_get ( tss_t  key)

◆ tss_set()

_PUBLIC int tss_set ( tss_t  key,
void *  val 
)