2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 #include "cmogstored.h"
6 #ifndef HAVE_PTHREAD_YIELD
7 # define pthread_yield() (void)sched_yield()
11 * pthread_yield may migrate us to the same CPU as the task we're waiting
12 * on, so just keep yielding for every CPU we have as this throttles
13 * our ability to spam SIGURG. This means the threads we're trying to
14 * gracefully kill off can finish their work and check their mog_do_quit
17 * We only use this as a last resort when normal wakeups/notifications
18 * are not usable (e.g. recovering from out-of-resource problems)
22 static unsigned long nproc_all
;
26 nproc_all
= num_processors(NPROC_ALL
) * 2;
27 for (i
= 0; i
< nproc_all
; i
++)