diff options
author | davidxu <davidxu@FreeBSD.org> | 2003-12-09 02:20:56 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2003-12-09 02:20:56 +0000 |
commit | 22c52834eb703c132b4e7c6bd591610f1129d32d (patch) | |
tree | 336614966b1df2677098ac89ea3a03fc82f7141b /lib/libkse/thread/thr_kern.c | |
parent | 84e2c4c55b82cc4f62ab90c4141beffce4e30412 (diff) | |
download | FreeBSD-src-22c52834eb703c132b4e7c6bd591610f1129d32d.zip FreeBSD-src-22c52834eb703c132b4e7c6bd591610f1129d32d.tar.gz |
Rename _thr_enter_cancellation_point to _thr_cancel_enter, rename
_thr_leave_cancellation_point to _thr_cancel_leave, add a parameter
to _thr_cancel_leave to indicate whether cancellation point should be
checked, this gives us an option to not check cancallation point if
a syscall successfully returns to avoid any leaks, current I have
creat(), open() and fcntl(F_DUPFD) to not check cancellation point
after they sucessfully returned.
Replace some members in structure kse with bit flags to same some
memory.
Conditionally compile THR_ASSERT to nothing if _PTHREAD_INVARIANTS is
not defined.
Inline some small functions in thr_cancel.c.
Use __predict_false in thr_kern.c for some executed only once code.
Reviewd by: deischen
Diffstat (limited to 'lib/libkse/thread/thr_kern.c')
-rw-r--r-- | lib/libkse/thread/thr_kern.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index 7fd8b38..a5d068b 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -389,12 +389,6 @@ _kse_init(void) } } -int -_kse_isthreaded(void) -{ - return (__isthreaded != 0); -} - /* * This is called when the first thread (other than the initial * thread) is created. @@ -636,7 +630,7 @@ _thr_sched_switch_unlocked(struct pthread *curthread) if (curthread->attr.flags & PTHREAD_SCOPE_SYSTEM) kse_sched_single(&curkse->k_kcb->kcb_kmbx); else { - curkse->k_switch = 1; + KSE_SET_SWITCH(curkse); _thread_enter_uts(curthread->tcb, curkse->k_kcb); } @@ -696,7 +690,7 @@ kse_sched_single(struct kse_mailbox *kmbx) curkse = (struct kse *)kmbx->km_udata; curthread = curkse->k_curthread; - if ((curkse->k_flags & KF_INITIALIZED) == 0) { + if (__predict_false((curkse->k_flags & KF_INITIALIZED) == 0)) { /* Setup this KSEs specific data. */ _kcb_set(curkse->k_kcb); _tcb_set(curkse->k_kcb, curthread->tcb); @@ -914,7 +908,7 @@ kse_sched_multi(struct kse_mailbox *kmbx) "Mailbox not null in kse_sched_multi"); /* Check for first time initialization: */ - if ((curkse->k_flags & KF_INITIALIZED) == 0) { + if (__predict_false((curkse->k_flags & KF_INITIALIZED) == 0)) { /* Setup this KSEs specific data. */ _kcb_set(curkse->k_kcb); @@ -929,9 +923,15 @@ kse_sched_multi(struct kse_mailbox *kmbx) _tcb_set(curkse->k_kcb, NULL); /* If this is an upcall; take the scheduler lock. */ - if (curkse->k_switch == 0) + if (!KSE_IS_SWITCH(curkse)) KSE_SCHED_LOCK(curkse, curkse->k_kseg); - curkse->k_switch = 0; + else + KSE_CLEAR_SWITCH(curkse); + + if (KSE_IS_IDLE(curkse)) { + KSE_CLEAR_IDLE(curkse); + curkse->k_kseg->kg_idle_kses--; + } /* * Now that the scheduler lock is held, get the current @@ -941,10 +941,6 @@ kse_sched_multi(struct kse_mailbox *kmbx) */ curthread = curkse->k_curthread; - if (KSE_IS_IDLE(curkse)) { - KSE_CLEAR_IDLE(curkse); - curkse->k_kseg->kg_idle_kses--; - } /* * If the current thread was completed in another KSE, then * it will be in the run queue. Don't mark it as being blocked. @@ -2295,11 +2291,8 @@ kse_reinit(struct kse *kse, int sys_scope) kse->k_schedq = 0; kse->k_locklevel = 0; kse->k_flags = 0; - kse->k_idle = 0; kse->k_error = 0; kse->k_cpu = 0; - kse->k_done = 0; - kse->k_switch = 0; kse->k_sigseqno = 0; } |