Clean bound and non-bound pthread structures consistently before
they become candidates for reuse. Without this fix, some of the state from a thread structure's previous incarnation could interfere with its new one. Specifically, a non-bound thread started as "suspended" (see pthread_attr_setcreatesuspend_np()) might not get scheduled at all when resumed, as the "active" flag would be set spuriously. Reviewed by: deischen@, davidxu@ MFC after: 1 week
This commit is contained in:
parent
7c929cf95b
commit
977e36e94a
@ -764,7 +764,6 @@ kse_sched_single(struct kse_mailbox *kmbx)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PS_DEAD:
|
case PS_DEAD:
|
||||||
curthread->check_pending = 0;
|
|
||||||
/* Unlock the scheduling queue and exit the KSE and thread. */
|
/* Unlock the scheduling queue and exit the KSE and thread. */
|
||||||
thr_cleanup(curkse, curthread);
|
thr_cleanup(curkse, curthread);
|
||||||
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
|
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
|
||||||
@ -1150,6 +1149,11 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
|
|||||||
struct kse_mailbox *kmbx = NULL;
|
struct kse_mailbox *kmbx = NULL;
|
||||||
int sys_scope;
|
int sys_scope;
|
||||||
|
|
||||||
|
thread->active = 0;
|
||||||
|
thread->need_switchout = 0;
|
||||||
|
thread->lock_switch = 0;
|
||||||
|
thread->check_pending = 0;
|
||||||
|
|
||||||
if ((joiner = thread->joiner) != NULL) {
|
if ((joiner = thread->joiner) != NULL) {
|
||||||
/* Joinee scheduler lock held; joiner won't leave. */
|
/* Joinee scheduler lock held; joiner won't leave. */
|
||||||
if (joiner->kseg == curkse->k_kseg) {
|
if (joiner->kseg == curkse->k_kseg) {
|
||||||
@ -1717,9 +1721,6 @@ kse_switchout_thread(struct kse *kse, struct pthread *thread)
|
|||||||
* stack. It is safe to do garbage collecting
|
* stack. It is safe to do garbage collecting
|
||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
thread->active = 0;
|
|
||||||
thread->need_switchout = 0;
|
|
||||||
thread->lock_switch = 0;
|
|
||||||
thr_cleanup(kse, thread);
|
thr_cleanup(kse, thread);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
@ -764,7 +764,6 @@ kse_sched_single(struct kse_mailbox *kmbx)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PS_DEAD:
|
case PS_DEAD:
|
||||||
curthread->check_pending = 0;
|
|
||||||
/* Unlock the scheduling queue and exit the KSE and thread. */
|
/* Unlock the scheduling queue and exit the KSE and thread. */
|
||||||
thr_cleanup(curkse, curthread);
|
thr_cleanup(curkse, curthread);
|
||||||
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
|
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
|
||||||
@ -1150,6 +1149,11 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
|
|||||||
struct kse_mailbox *kmbx = NULL;
|
struct kse_mailbox *kmbx = NULL;
|
||||||
int sys_scope;
|
int sys_scope;
|
||||||
|
|
||||||
|
thread->active = 0;
|
||||||
|
thread->need_switchout = 0;
|
||||||
|
thread->lock_switch = 0;
|
||||||
|
thread->check_pending = 0;
|
||||||
|
|
||||||
if ((joiner = thread->joiner) != NULL) {
|
if ((joiner = thread->joiner) != NULL) {
|
||||||
/* Joinee scheduler lock held; joiner won't leave. */
|
/* Joinee scheduler lock held; joiner won't leave. */
|
||||||
if (joiner->kseg == curkse->k_kseg) {
|
if (joiner->kseg == curkse->k_kseg) {
|
||||||
@ -1717,9 +1721,6 @@ kse_switchout_thread(struct kse *kse, struct pthread *thread)
|
|||||||
* stack. It is safe to do garbage collecting
|
* stack. It is safe to do garbage collecting
|
||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
thread->active = 0;
|
|
||||||
thread->need_switchout = 0;
|
|
||||||
thread->lock_switch = 0;
|
|
||||||
thr_cleanup(kse, thread);
|
thr_cleanup(kse, thread);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user