diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-06-21 03:34:36 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-06-25 22:07:42 +0000 |
commit | e12e70b6bd242cb3fea74d1df8b7b44e0a9f7f26 (patch) | |
tree | 49f915d77028ae98852243efed2ab3c7c8323660 /thrpool.c | |
parent | a18a08a0e9a7c472656afc86cbbbfcefda5e456d (diff) | |
download | cmogstored-e12e70b6bd242cb3fea74d1df8b7b44e0a9f7f26.tar.gz |
While pthread_yield is non-standard, it is relatively common and preferable for systems where pthreads are _not_ 1:1 mapped to kernel threads. This also provides a stronger yield to weaken the priority of the calling thread wherever we previously used sched_yield.
Diffstat (limited to 'thrpool.c')
-rw-r--r-- | thrpool.c | 22 |
1 files changed, 2 insertions, 20 deletions
@@ -67,24 +67,6 @@ void mog_thr_test_quit(void) } /* - * sched_yield may migrate us to the same CPU as the task we're waiting - * on, so just keep yielding for every CPU we have as this throttles - * our ability to spam SIGURG. This means the threads we're trying to - * gracefully kill off can finish their work and check their mog_do_quit - * flag sooner - */ -static void yield_all(void) -{ - static unsigned long nproc_all; - unsigned long i; - - if (!nproc_all) - nproc_all = num_processors(NPROC_ALL) * 2; - for (i = 0; i < nproc_all; i++) - pthread_yield(); -} - -/* * we no longer rely on pthreads cancellation, so our explicit checks for * thread quitting requires us to continuously signal a thread for death * in case it enters a sleeping syscall (epoll_wait/kevent) immediately @@ -99,7 +81,7 @@ static void poke(pthread_t thr, int sig) * we lower thread counts or shut down */ while ((err = pthread_kill(thr, sig)) == 0) - yield_all(); + mog_yield(); assert(err == ESRCH && "pthread_kill() usage bug"); } @@ -115,7 +97,7 @@ thr_create_fail_retry(struct mog_thrpool *tp, size_t size, syslog(LOG_ERR, "pthread_create: %m (tries: %lu)", *nr_eagain); } - yield_all(); + mog_yield(); return true; } else { errno = err; |