MFp4:
Enqueue thread in LIFO, this can cause starvation, but it gives better performance. Use _thr_queuefifo to control the frequency of FIFO vs LIFO, you can use environment string LIBPTHREAD_QUEUE_FIFO to configure the variable.
This commit is contained in:
parent
bdf942c3f0
commit
84ac0fb8ca
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=234947
@ -112,6 +112,7 @@ size_t _thr_stack_initial = THR_STACK_INITIAL;
|
||||
int _thr_page_size;
|
||||
int _thr_spinloops;
|
||||
int _thr_yieldloops;
|
||||
int _thr_queuefifo = 4;
|
||||
int _gc_count;
|
||||
struct umutex _mutex_static_lock = DEFAULT_UMUTEX;
|
||||
struct umutex _cond_static_lock = DEFAULT_UMUTEX;
|
||||
@ -470,6 +471,9 @@ init_private(void)
|
||||
env = getenv("LIBPTHREAD_YIELDLOOPS");
|
||||
if (env)
|
||||
_thr_yieldloops = atoi(env);
|
||||
env = getenv("LIBPTHREAD_QUEUE_FIFO");
|
||||
if (env)
|
||||
_thr_queuefifo = atoi(env);
|
||||
TAILQ_INIT(&_thr_atfork_list);
|
||||
}
|
||||
init_once = 1;
|
||||
|
@ -710,6 +710,7 @@ extern size_t _thr_stack_initial __hidden;
|
||||
extern int _thr_page_size __hidden;
|
||||
extern int _thr_spinloops __hidden;
|
||||
extern int _thr_yieldloops __hidden;
|
||||
extern int _thr_queuefifo __hidden;
|
||||
|
||||
/* Garbage thread count. */
|
||||
extern int _gc_count __hidden;
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
struct sleepqueue_chain {
|
||||
struct umutex sc_lock;
|
||||
int sc_enqcnt;
|
||||
LIST_HEAD(, sleepqueue) sc_queues;
|
||||
int sc_type;
|
||||
};
|
||||
@ -124,7 +125,10 @@ _sleepq_add(void *wchan, struct pthread *td)
|
||||
}
|
||||
td->sleepqueue = NULL;
|
||||
td->wchan = wchan;
|
||||
TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle);
|
||||
if (((++sc->sc_enqcnt << _thr_queuefifo) & 0xff) != 0)
|
||||
TAILQ_INSERT_HEAD(&sq->sq_blocked, td, wle);
|
||||
else
|
||||
TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user