mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Improve pthread_join()
Since we're now on Windows 8, we can have clone() work as advertised on Windows, where it sends a futex wake to the child tid. It's also likely we no longer need to work around thread flakes on OpenBSD, in _wait0().
This commit is contained in:
parent
3733b43a8f
commit
994e1f4386
19 changed files with 154 additions and 74 deletions
|
@ -17,18 +17,18 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/_getauxval.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
static struct {
|
||||
int thepid;
|
||||
uint128_t thepool;
|
||||
pthread_mutex_t lock;
|
||||
pthread_spinlock_t lock;
|
||||
} g_rand64;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ static struct {
|
|||
uint64_t rand64(void) {
|
||||
void *p;
|
||||
uint128_t s;
|
||||
if (__threaded) pthread_mutex_lock(&g_rand64.lock);
|
||||
if (__threaded) pthread_spin_lock(&g_rand64.lock);
|
||||
if (__pid == g_rand64.thepid) {
|
||||
s = g_rand64.thepool; // normal path
|
||||
} else {
|
||||
|
@ -70,6 +70,6 @@ uint64_t rand64(void) {
|
|||
g_rand64.thepid = __pid;
|
||||
}
|
||||
g_rand64.thepool = (s *= 15750249268501108917ull); // lemur64
|
||||
if (__threaded) pthread_mutex_unlock(&g_rand64.lock);
|
||||
pthread_spin_unlock(&g_rand64.lock);
|
||||
return s >> 64;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue