mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-21 21:49:03 +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
23 lines
520 B
C
23 lines
520 B
C
#ifndef COSMOPOLITAN_LIBC_ITIMER_H_
|
|
#define COSMOPOLITAN_LIBC_ITIMER_H_
|
|
#include "libc/atomic.h"
|
|
#include "libc/calls/struct/itimerval.h"
|
|
#include "libc/thread/thread.h"
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct IntervalTimer {
|
|
atomic_uint once;
|
|
intptr_t thread;
|
|
pthread_mutex_t lock;
|
|
pthread_cond_t cond;
|
|
struct itimerval it;
|
|
};
|
|
|
|
extern struct IntervalTimer __itimer;
|
|
|
|
void __itimer_lock(void);
|
|
void __itimer_unlock(void);
|
|
void __itimer_wipe_and_reset(void);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* COSMOPOLITAN_LIBC_ITIMER_H_ */
|