mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
[WIP] Threading (#282)
* Thread creation * Proper thread creation and exit * Join/Detach protocol * Added semaphore with futex (hopefully fast)
This commit is contained in:
parent
d852640a1e
commit
a0b39f886c
30 changed files with 792 additions and 12 deletions
36
libc/thread/attr.h
Normal file
36
libc/thread/attr.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_THREAD_ATTR_H_
|
||||
#define COSMOPOLITAN_LIBC_THREAD_ATTR_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/**
|
||||
* @fileoverview cosmopolitan thread attributes
|
||||
*/
|
||||
|
||||
#define CTHREAD_CREATE_DETACHED 1
|
||||
#define CTHREAD_CREATE_JOINABLE 0
|
||||
|
||||
typedef struct cthread_attr_t {
|
||||
size_t stacksize, guardsize;
|
||||
int mode;
|
||||
} cthread_attr_t;
|
||||
|
||||
// CTOR/DTOR
|
||||
int cthread_attr_init(cthread_attr_t*);
|
||||
int cthread_attr_destroy(cthread_attr_t*);
|
||||
|
||||
// stacksize
|
||||
int cthread_attr_setstacksize(cthread_attr_t*, size_t);
|
||||
size_t thread_attr_getstacksize(const cthread_attr_t*);
|
||||
|
||||
// guardsize
|
||||
int cthread_attr_setguardsize(cthread_attr_t*, size_t);
|
||||
size_t cthread_attr_getguardsize(const cthread_attr_t*);
|
||||
|
||||
// detachstate
|
||||
int cthread_attr_setdetachstate(cthread_attr_t*, int);
|
||||
int cthread_attr_getdetachstate(const cthread_attr_t*);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_THREAD_ATTR_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue