summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_cancel.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2003-07-23 02:11:07 +0000
committerdeischen <deischen@FreeBSD.org>2003-07-23 02:11:07 +0000
commit9f8651cad61cf131bd07594ac25f3cd102fe0159 (patch)
tree2ba938226cb9f3c751737df74c5cdf8e63cf8eba /lib/libkse/thread/thr_cancel.c
parenta8317490154f61e26d775ebd4480ec6333f94a75 (diff)
downloadFreeBSD-src-9f8651cad61cf131bd07594ac25f3cd102fe0159.zip
FreeBSD-src-9f8651cad61cf131bd07594ac25f3cd102fe0159.tar.gz
Move idle kse wakeup to outside of regions where locks are held.
This eliminates ping-ponging of locks, where the idle KSE wakes up only to find the lock it needs is being held. This gives little or no gain to M:N mode but greatly speeds up 1:1 mode. Reviewed & Tested by: davidxu
Diffstat (limited to 'lib/libkse/thread/thr_cancel.c')
-rw-r--r--lib/libkse/thread/thr_cancel.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libkse/thread/thr_cancel.c b/lib/libkse/thread/thr_cancel.c
index 731a9aa..581b719 100644
--- a/lib/libkse/thread/thr_cancel.c
+++ b/lib/libkse/thread/thr_cancel.c
@@ -20,6 +20,7 @@ _pthread_cancel(pthread_t pthread)
{
struct pthread *curthread = _get_curthread();
struct pthread *joinee = NULL;
+ struct kse_mailbox *kmbx = NULL;
int ret;
if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) == 0) {
@@ -65,7 +66,7 @@ _pthread_cancel(pthread_t pthread)
/* Interrupt and resume: */
pthread->interrupted = 1;
pthread->cancelflags |= THR_CANCELLING;
- _thr_setrunnable_unlocked(pthread);
+ kmbx = _thr_setrunnable_unlocked(pthread);
break;
case PS_JOIN:
@@ -73,7 +74,7 @@ _pthread_cancel(pthread_t pthread)
joinee = pthread->join_status.thread;
pthread->join_status.thread = NULL;
pthread->cancelflags |= THR_CANCELLING;
- _thr_setrunnable_unlocked(pthread);
+ kmbx = _thr_setrunnable_unlocked(pthread);
if ((joinee != NULL) &&
(pthread->kseg == joinee->kseg)) {
/* Remove the joiner from the joinee. */
@@ -97,7 +98,7 @@ _pthread_cancel(pthread_t pthread)
*/
pthread->interrupted = 1;
pthread->cancelflags |= THR_CANCEL_NEEDED;
- _thr_setrunnable_unlocked(pthread);
+ kmbx = _thr_setrunnable_unlocked(pthread);
pthread->continuation = finish_cancellation;
break;
@@ -120,6 +121,8 @@ _pthread_cancel(pthread_t pthread)
*/
THR_SCHED_UNLOCK(curthread, pthread);
_thr_ref_delete(curthread, pthread);
+ if (kmbx != NULL)
+ kse_wakeup(kmbx);
if ((joinee != NULL) &&
(_thr_ref_add(curthread, joinee, /* include dead */1) == 0)) {
OpenPOWER on IntegriCloud