mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-31 17:52:27 +00:00
Improve multithreading
This commit is contained in:
parent
d3167126aa
commit
30afd6ddbb
38 changed files with 752 additions and 174 deletions
|
@ -74,7 +74,7 @@ struct PosixThread {
|
|||
atomic_int pt_canceled; // 0x04: thread has bad beliefs
|
||||
_Atomic(enum PosixThreadStatus) pt_status;
|
||||
atomic_int ptid; // transitions 0 → tid
|
||||
atomic_int pt_refs; // negative means free
|
||||
atomic_int pt_refs; // prevents decimation
|
||||
void *(*pt_start)(void *); // creation callback
|
||||
void *pt_arg; // start's parameter
|
||||
void *pt_rc; // start's return value
|
||||
|
@ -103,14 +103,13 @@ int _pthread_setschedparam_freebsd(int, int, const struct sched_param *);
|
|||
int _pthread_tid(struct PosixThread *) libcesque;
|
||||
intptr_t _pthread_syshand(struct PosixThread *) libcesque;
|
||||
long _pthread_cancel_ack(void) libcesque;
|
||||
void _pthread_decimate(void) libcesque;
|
||||
void _pthread_free(struct PosixThread *, bool) libcesque;
|
||||
void _pthread_decimate(bool) libcesque;
|
||||
void _pthread_free(struct PosixThread *) libcesque;
|
||||
void _pthread_lock(void) libcesque;
|
||||
void _pthread_onfork_child(void) libcesque;
|
||||
void _pthread_onfork_parent(void) libcesque;
|
||||
void _pthread_onfork_prepare(void) libcesque;
|
||||
void _pthread_unlock(void) libcesque;
|
||||
void _pthread_unref(struct PosixThread *) libcesque;
|
||||
void _pthread_zombify(struct PosixThread *) libcesque;
|
||||
|
||||
forceinline pureconst struct PosixThread *_pthread_self(void) {
|
||||
|
@ -118,7 +117,11 @@ forceinline pureconst struct PosixThread *_pthread_self(void) {
|
|||
}
|
||||
|
||||
forceinline void _pthread_ref(struct PosixThread *pt) {
|
||||
atomic_fetch_add_explicit(&pt->pt_refs, 1, memory_order_relaxed);
|
||||
atomic_fetch_add_explicit(&pt->pt_refs, 1, memory_order_acq_rel);
|
||||
}
|
||||
|
||||
forceinline void _pthread_unref(struct PosixThread *pt) {
|
||||
atomic_fetch_sub_explicit(&pt->pt_refs, 1, memory_order_acq_rel);
|
||||
}
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue