mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Make detached threads work better
This change adds a double linked list of threads, so that pthread_exit() will know when it should call exit() from an orphaned child. This change also improves ftrace and strace logging.
This commit is contained in:
parent
b74d8c1acd
commit
cee6871710
37 changed files with 638 additions and 314 deletions
|
@ -54,16 +54,11 @@ 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;
|
||||
|
@ -279,4 +274,7 @@ BENCH(pthread_create, bench) {
|
|||
EZBENCH2("CreateJoin", donothing, CreateJoin());
|
||||
EZBENCH2("CreateDetach", donothing, CreateDetach());
|
||||
EZBENCH2("CreateDetached", donothing, CreateDetached());
|
||||
while (!pthread_orphan_np()) {
|
||||
pthread_decimate_np();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue