summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_sleepq.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-05-03 09:17:31 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-05-03 09:17:31 +0000
commit520dba8f2897914f2ceccc1e916009a3b00c3ad9 (patch)
treeed9550b886413ddf07f7d057d29b37d1ce5bce06 /lib/libthr/thread/thr_sleepq.c
parent46b1e41aff0313c3b831f1bdfbc076495fd68fbc (diff)
downloadFreeBSD-src-520dba8f2897914f2ceccc1e916009a3b00c3ad9.zip
FreeBSD-src-520dba8f2897914f2ceccc1e916009a3b00c3ad9.tar.gz
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.
Diffstat (limited to 'lib/libthr/thread/thr_sleepq.c')
-rw-r--r--lib/libthr/thread/thr_sleepq.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_sleepq.c b/lib/libthr/thread/thr_sleepq.c
index 8549a87..40553cb 100644
--- a/lib/libthr/thread/thr_sleepq.c
+++ b/lib/libthr/thread/thr_sleepq.c
@@ -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
OpenPOWER on IntegriCloud