diff options
Diffstat (limited to 'thrpool.c')
-rw-r--r-- | thrpool.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -86,9 +86,18 @@ static void poke(pthread_t thr, int sig) * This is an uncommon code path and only triggered when * we lower thread counts or shut down */ - while ((err = pthread_kill(thr, sig)) == 0) - mog_yield(); - + while ((err = pthread_kill(thr, sig)) == 0) { + /* + * sleep for 10 ms, sched_yield still burns too much CPU + * on FreeBSD (and likely other OSes) if a thread is waiting + * on disk I/O. + */ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 10e6 }; + int rc = nanosleep(&ts, NULL); + + if (rc != 0) + assert(errno != EINVAL && "bug in using nanosleep"); + } assert(err == ESRCH && "pthread_kill() usage bug"); } |