Revert "Make spin locks go faster"

This reverts commit c8e25d811c.
This commit is contained in:
Justine Tunney 2024-07-25 22:24:32 -07:00
parent 0679cfeb41
commit 02e1cbcd00
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
16 changed files with 122 additions and 149 deletions

View file

@ -30,27 +30,15 @@
static int cpus;
static double load;
static pthread_spinlock_t lock;
static struct NtFileTime idle1, kern1, user1;
static pthread_mutex_t getloadavg_lock;
static void __getloadavg_lock(void) {
pthread_mutex_lock(&getloadavg_lock);
}
static void __getloadavg_unlock(void) {
pthread_mutex_unlock(&getloadavg_lock);
}
static void __getloadavg_wipe(void) {
pthread_mutex_init(&getloadavg_lock, 0);
}
textwindows int sys_getloadavg_nt(double *a, int n) {
int i, rc;
uint64_t elapsed, used;
struct NtFileTime idle, kern, user;
BLOCK_SIGNALS;
__getloadavg_lock();
pthread_spin_lock(&lock);
if (GetSystemTimes(&idle, &kern, &user)) {
elapsed = (FT(kern) - FT(kern1)) + (FT(user) - FT(user1));
if (elapsed) {
@ -66,7 +54,7 @@ textwindows int sys_getloadavg_nt(double *a, int n) {
} else {
rc = __winerr();
}
__getloadavg_unlock();
pthread_spin_unlock(&lock);
ALLOW_SIGNALS;
return rc;
}
@ -77,7 +65,5 @@ __attribute__((__constructor__(40))) static textstartup void ntinitload(void) {
cpus = __get_cpu_count() / 2;
cpus = MAX(1, cpus);
GetSystemTimes(&idle1, &kern1, &user1);
pthread_atfork(__getloadavg_lock, __getloadavg_unlock, __getloadavg_wipe);
__getloadavg_wipe();
}
}