Subject: SZOMB state in lwp_exit2()
To: None <tech-kern@NetBSD.org>
From: Bang Jun-Young <junyoung@NetBSD.org>
List: tech-kern
Date: 03/04/2004 15:51:16
Currenty, lwp_exit2() is as follows:
void
lwp_exit2(struct lwp *l)
{
struct proc *p;
KERNEL_LOCK(LK_EXCLUSIVE);
/*
* Free the VM resources we're still holding on to.
*/
uvm_lwp_exit(l);
l->l_stat = LSZOMB;
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 {
p = l->l_proc;
p->p_nzlwps++;
KERNEL_UNLOCK();
wakeup(&p->p_nlwps);
}
}
It's not clear to me why lwp state is set to SZOMB for detached lwp as well,
which is very soon to be freed. Wouldn't it be more approproate if it was
like this:
Index: kern_lwp.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_lwp.c,v
retrieving revision 1.25
diff -u -r1.25 kern_lwp.c
--- kern_lwp.c 2 Mar 2004 09:15:26 -0000 1.25
+++ kern_lwp.c 4 Mar 2004 06:47:01 -0000
@@ -596,7 +596,6 @@
*/
uvm_lwp_exit(l);
- l->l_stat = LSZOMB;
if (l->l_flag & L_DETACHED) {
/* Nobody waits for detached LWPs. */
@@ -609,6 +608,7 @@
pool_put(&lwp_pool, l);
KERNEL_UNLOCK();
} else {
+ l->l_stat = LSZOMB;
p = l->l_proc;
p->p_nzlwps++;
KERNEL_UNLOCK();
Jun-Young