simplify lwp exit code.

This commit is contained in:
yamt 2005-10-01 06:12:44 +00:00
parent 39e9173002
commit f615d37667
3 changed files with 19 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exit.c,v 1.151 2005/08/28 14:57:18 yamt Exp $ */
/* $NetBSD: kern_exit.c,v 1.152 2005/10/01 06:12:44 yamt Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.151 2005/08/28 14:57:18 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.152 2005/10/01 06:12:44 yamt Exp $");
#include "opt_ktrace.h"
#include "opt_perfctrs.h"
@ -443,7 +443,7 @@ exit1(struct lwp *l, int rv)
LIST_REMOVE(l, l_list);
LIST_REMOVE(l, l_sibling);
l->l_flag |= L_DETACHED|L_PROCEXIT; /* detached from proc too */
l->l_flag |= L_DETACHED; /* detached from proc too */
l->l_stat = LSDEAD;
KASSERT(p->p_nrlwps == 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.30 2005/08/28 14:57:18 yamt Exp $ */
/* $NetBSD: kern_lwp.c,v 1.31 2005/10/01 06:12:44 yamt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.30 2005/08/28 14:57:18 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.31 2005/10/01 06:12:44 yamt Exp $");
#include "opt_multiprocessor.h"
@ -557,6 +557,19 @@ lwp_exit(struct lwp *l)
cpu_lwp_free(l, 0);
#endif
pmap_deactivate(l);
if (l->l_flag & L_DETACHED) {
simple_lock(&p->p_lock);
LIST_REMOVE(l, l_sibling);
p = l->l_proc;
p->p_nlwps--;
simple_unlock(&p->p_lock);
curlwp = NULL;
l->l_proc = NULL;
}
SCHED_LOCK(s);
p->p_nrlwps--;
l->l_stat = LSDEAD;
@ -565,8 +578,6 @@ lwp_exit(struct lwp *l)
/* This LWP no longer needs to hold the kernel lock. */
KERNEL_PROC_UNLOCK(l);
pmap_deactivate(l);
/* cpu_exit() will not return */
cpu_exit(l);
}
@ -593,13 +604,6 @@ lwp_exit2(struct lwp *l)
if (l->l_flag & L_DETACHED) {
/* Nobody waits for detached LWPs. */
if ((l->l_flag & L_PROCEXIT) == 0) {
LIST_REMOVE(l, l_sibling);
p = l->l_proc;
p->p_nlwps--;
}
pool_put(&lwp_pool, l);
KERNEL_UNLOCK();
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lwp.h,v 1.29 2005/07/16 17:50:26 christos Exp $ */
/* $NetBSD: lwp.h,v 1.30 2005/10/01 06:12:44 yamt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -108,7 +108,6 @@ extern struct lwp lwp0; /* LWP for proc0 */
#define L_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */
#define L_SINTR 0x00080 /* Sleep is interruptible. */
#define L_TIMEOUT 0x00400 /* Timing out during sleep. */
#define L_PROCEXIT 0x00800 /* In process exit, l_proc no longer valid */
#define L_SA 0x100000 /* Scheduler activations LWP */
#define L_SA_UPCALL 0x200000 /* SA upcall is pending */
#define L_SA_BLOCKING 0x400000 /* Blocking in tsleep() */