summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_cond.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2003-07-18 02:46:30 +0000
committerdeischen <deischen@FreeBSD.org>2003-07-18 02:46:30 +0000
commit875c5215cc8eb12453d2815a29a56842237d4327 (patch)
treeb47c0a599d105c7a35e226f6b60c3c2afc7eb204 /lib/libpthread/thread/thr_cond.c
parent1d77fe8eb48f2bc045975da4f4e8914083417a6c (diff)
downloadFreeBSD-src-875c5215cc8eb12453d2815a29a56842237d4327.zip
FreeBSD-src-875c5215cc8eb12453d2815a29a56842237d4327.tar.gz
Add a preemption point when a mutex or condition variable is
handed-off/signaled to a higher priority thread. Note that when there are idle KSEs that could run the higher priority thread, we still add the preemption point because it seems to take the kernel a while to schedule an idle KSE. The drawbacks are that threads will be swapped more often between CPUs (KSEs) and that there will be an extra userland context switch (the idle KSE is still woken and will probably resume the preempted thread). We'll revisit this if and when idle CPU/KSE wakeup times improve. Inspired by: Petri Helenius <pete@he.iki.fi> Reviewed by: davidxu
Diffstat (limited to 'lib/libpthread/thread/thr_cond.c')
-rw-r--r--lib/libpthread/thread/thr_cond.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c
index 9e73c61..9703da6 100644
--- a/lib/libpthread/thread/thr_cond.c
+++ b/lib/libpthread/thread/thr_cond.c
@@ -615,6 +615,10 @@ _pthread_cond_signal(pthread_cond_t * cond)
!= NULL) {
THR_SCHED_LOCK(curthread, pthread);
cond_queue_remove(*cond, pthread);
+ if ((pthread->kseg == curthread->kseg) &&
+ (pthread->active_priority >
+ curthread->active_priority))
+ curthread->critical_yield = 1;
_thr_setrunnable_unlocked(pthread);
THR_SCHED_UNLOCK(curthread, pthread);
}
@@ -674,6 +678,10 @@ _pthread_cond_broadcast(pthread_cond_t * cond)
!= NULL) {
THR_SCHED_LOCK(curthread, pthread);
cond_queue_remove(*cond, pthread);
+ if ((pthread->kseg == curthread->kseg) &&
+ (pthread->active_priority >
+ curthread->active_priority))
+ curthread->critical_yield = 1;
_thr_setrunnable_unlocked(pthread);
THR_SCHED_UNLOCK(curthread, pthread);
}
OpenPOWER on IntegriCloud