From 0222ac9cec9300767b18b2973ef57ae942fe6478 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 28 Feb 2018 10:25:08 -0800 Subject: [PATCH] Rune - Check thread stats more often * Check the thread stats more often to determine when more real pthreads are needed. --- libruntime/thread.c | 2 ++ tests/threadov.d | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libruntime/thread.c b/libruntime/thread.c index cd04568..cb14bfe 100644 --- a/libruntime/thread.c +++ b/libruntime/thread.c @@ -692,6 +692,7 @@ threadStart(runethr_t *td, pthread_mutex_t *lmtx) if (IsSMP) pthread_cond_signal(&IdleCond); threadMutexUnlock(&SchedMtx); + checkNeedMoreThreads(); } threadMutexUnlock(mtx); } @@ -1053,6 +1054,7 @@ threadDetachSynchronous(void) */ errno = ntd->td_SaveErrno; threadMutexUnlock(&SchedMtx); + checkNeedMoreThreads(); rgd = getrgd(); if (rgd->SwitchMtx) { threadMutexUnlock(rgd->SwitchMtx); diff --git a/tests/threadov.d b/tests/threadov.d index d4f4042..b4c8d9f 100755 --- a/tests/threadov.d +++ b/tests/threadov.d @@ -33,11 +33,14 @@ main(int ac, char **av) # here. # for (i = 0; i < 1000000; ++i) { - test3(); + if (i % 10000 == 0) + stdout->format("started %d\n", i); + test3(i); } break; } - stdio.stdout->show("finished loops"); + stdio.stdout->show("finished all starts"); + Thread.waitThreads(); } void @@ -53,7 +56,17 @@ test2() thread void -test3() +test3(int i) { + int l = i; + result; + Thread.mssleep(10000); + for (;;) { + Thread.mssleep(2000); + if (l == 0) + stdout->show("loop"); + else + ; + } } -- 2.41.0