mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48: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
|
@ -81,7 +81,7 @@ BENCH(lock, scalability) {
|
|||
pthread_barrier_destroy(&barrier);
|
||||
pthread_mutex_destroy(&lock);
|
||||
t2 = _timespec_real();
|
||||
printf("consumed %10g seconds monotonic time and %10g seconds cpu time\n",
|
||||
_timespec_tonanos(_timespec_sub(t2, t1)) / 1000000000.,
|
||||
printf("consumed %10g seconds real time and %10g seconds cpu time\n",
|
||||
_timespec_tonanos(_timespec_sub(t2, t1)) / 1e9,
|
||||
(double)clock() / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
|
|
@ -18,29 +18,18 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/clone.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/thread/spawn.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
#define THREADS 8
|
||||
#define ENTRIES 1024
|
||||
#define ENTRIES 100
|
||||
|
||||
volatile uint64_t A[THREADS * ENTRIES];
|
||||
pthread_barrier_t barrier;
|
||||
|
|
|
@ -54,11 +54,16 @@ void TriggerSignal(void) {
|
|||
}
|
||||
|
||||
static void *Increment(void *arg) {
|
||||
ASSERT_EQ(EDEADLK, pthread_join(pthread_self(), 0));
|
||||
ASSERT_EQ(gettid(), pthread_getthreadid_np());
|
||||
TriggerSignal();
|
||||
return (void *)((uintptr_t)arg + 1);
|
||||
}
|
||||
|
||||
TEST(pthread_create, joinSelfDeadlocks) {
|
||||
ASSERT_EQ(EDEADLK, pthread_join(pthread_self(), 0));
|
||||
}
|
||||
|
||||
TEST(pthread_create, testCreateReturnJoin) {
|
||||
void *rc;
|
||||
pthread_t id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue