mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
This change doubles the performance of thread spawning. That's thanks to our new stack manager, which allows us to avoid zeroing stacks. It gives us 15µs spawns rather than 30µs spawns on Linux. Also, pthread_exit() is faster now, since it doesn't need to acquire the pthread GIL. On NetBSD, that helps us avoid allocating too many semaphores. Even if that happens we're now able to survive semaphores running out and even memory running out, when allocating *NSYNC waiter objects. I found a lot more rare bugs in the POSIX threads runtime that could cause things to crash, if you've got dozens of threads all spawning and joining dozens of threads. I want cosmo to be world class production worthy for 2025 so happy holidays all
41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
#ifndef COSMOPOLITAN_LIBC_COSMO_H_
|
|
#define COSMOPOLITAN_LIBC_COSMO_H_
|
|
#include "libc/calls/struct/timespec.h"
|
|
COSMOPOLITAN_C_START_
|
|
|
|
#ifndef __cplusplus
|
|
#define _COSMO_ATOMIC(x) _Atomic(x)
|
|
#else
|
|
#define _COSMO_ATOMIC(x) x
|
|
#endif
|
|
|
|
errno_t cosmo_once(_COSMO_ATOMIC(unsigned) *, void (*)(void)) libcesque;
|
|
int systemvpe(const char *, char *const[], char *const[]) libcesque;
|
|
char *GetProgramExecutableName(void) libcesque;
|
|
void unleaf(void) libcesque;
|
|
bool32 IsLinuxModern(void) libcesque;
|
|
|
|
int __demangle(char *, const char *, size_t) libcesque;
|
|
int __is_mangled(const char *) libcesque;
|
|
|
|
int cosmo_args(const char *, char ***) libcesque;
|
|
int LoadZipArgs(int *, char ***) libcesque;
|
|
|
|
int cosmo_futex_wake(_COSMO_ATOMIC(int) *, int, char);
|
|
int cosmo_futex_wait(_COSMO_ATOMIC(int) *, int, char, int,
|
|
const struct timespec *);
|
|
|
|
errno_t cosmo_stack_alloc(size_t *, size_t *, void **) libcesque;
|
|
errno_t cosmo_stack_free(void *, size_t, size_t) libcesque;
|
|
void cosmo_stack_clear(void) libcesque;
|
|
void cosmo_stack_setmaxstacks(int) libcesque;
|
|
int cosmo_stack_getmaxstacks(void) libcesque;
|
|
|
|
int __deadlock_check(void *, int) libcesque;
|
|
int __deadlock_tracked(void *) libcesque;
|
|
void __deadlock_record(void *, int) libcesque;
|
|
void __deadlock_track(void *, int) libcesque;
|
|
void __deadlock_untrack(void *) libcesque;
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_COSMO_H_ */
|