Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Remove right duplication on thread creation, which becam...
details: https://anonhg.NetBSD.org/src/rev/568aad545b51
branches: trunk
changeset: 542312:568aad545b51
user: manu <manu%NetBSD.org@localhost>
date: Sun Jan 26 12:39:32 2003 +0000
description:
Remove right duplication on thread creation, which became useless now we
are using lwp.
Enable kill -9 to kill parent thread waiting for its child.
Use upcallret instead of child_return for the newly created lwp.
Add debug messages for thread creation.
Thread creation are still broken...
diffstat:
sys/arch/powerpc/powerpc/mach_machdep.c | 20 +++++----
sys/compat/mach/mach_thread.c | 62 +++-----------------------------
sys/compat/mach/mach_thread.h | 3 +-
3 files changed, 19 insertions(+), 66 deletions(-)
diffs (168 lines):
diff -r 0d87bbb1b885 -r 568aad545b51 sys/arch/powerpc/powerpc/mach_machdep.c
--- a/sys/arch/powerpc/powerpc/mach_machdep.c Sun Jan 26 07:07:31 2003 +0000
+++ b/sys/arch/powerpc/powerpc/mach_machdep.c Sun Jan 26 12:39:32 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_machdep.c,v 1.10 2003/01/21 04:06:08 matt Exp $ */
+/* $NetBSD: mach_machdep.c,v 1.11 2003/01/26 12:39:33 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.10 2003/01/21 04:06:08 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.11 2003/01/26 12:39:33 manu Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -122,6 +122,10 @@
struct trapframe *tf;
struct exec_macho_powerpc_thread_state *regs;
+#ifdef DEBUG_MACH
+ printf("entering mach_create_thread_child\n");
+#endif
+
mctc = (struct mach_create_thread_child_args *)arg;
l = mctc->mctc_lwp;
@@ -131,11 +135,6 @@
killproc(l->l_proc, "mach_create_thread_child: unknown flavor");
}
- /*
- * Copy right from parent. Will disappear the day we have struct lwp.
- */
- mach_copy_right(mctc->mctc_oldlwp, l);
-
tf = trapframe(l);
regs = (struct exec_macho_powerpc_thread_state *)mctc->mctc_state;
@@ -143,10 +142,10 @@
if ((regs->srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
uprintf("mach_create_thread_child: PSL_USERSTATIC change\n");
/*
- * Call child return before setting the register context as it
+ * Call upcallret before setting the register context as it
* affects R3, R4 and CR.
*/
- child_return((void *)l);
+ upcallret(l);
/* Set requested register context */
tf->srr0 = regs->srr0;
@@ -164,5 +163,8 @@
mctc->mctc_child_done = 1;
wakeup(&mctc->mctc_child_done);
+#ifdef DEBUG_MACH
+ printf("leaving mach_create_thread_child\n");
+#endif
return;
}
diff -r 0d87bbb1b885 -r 568aad545b51 sys/compat/mach/mach_thread.c
--- a/sys/compat/mach/mach_thread.c Sun Jan 26 07:07:31 2003 +0000
+++ b/sys/compat/mach/mach_thread.c Sun Jan 26 12:39:32 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_thread.c,v 1.14 2003/01/24 21:37:03 manu Exp $ */
+/* $NetBSD: mach_thread.c,v 1.15 2003/01/26 12:39:32 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.14 2003/01/24 21:37:03 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.15 2003/01/26 12:39:32 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -158,11 +158,13 @@
/*
* The child relies on some values in mctc, so we should not
- * exit until it is finished with it. We loop to avoid
- * spurious wakeups due to signals.
+ * exit until it is finished with it. We catch signals so that
+ * the process can be killed with kill -9, but we loop to avoid
+ * spurious wakeups due to other signals.
*/
while(mctc.mctc_child_done == 0)
- (void)tsleep(&mctc.mctc_child_done, PZERO, "mach_thread", 0);
+ (void)tsleep(&mctc.mctc_child_done,
+ PZERO|PCATCH, "mach_thread", 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
@@ -175,53 +177,3 @@
*msglen = sizeof(*rep);
return 0;
}
-
-/*
- * Duplicate the right of p1 into p2 on thread creation.
- * This will disappear the day we will have struct lwp.
- * XXX mr_p is not accurate anymore, this might introduce
- * some problems.
- */
-void
-mach_copy_right(l1, l2)
- struct lwp *l1;
- struct lwp *l2;
-{
- struct mach_emuldata *med1;
- struct mach_emuldata *med2;
- struct mach_right *mr;
-
- med1 = (struct mach_emuldata *)l1->l_proc->p_emuldata;
- med2 = (struct mach_emuldata *)l2->l_proc->p_emuldata;
-
- /* Undo what mach_e_proc_init did */
- if (--med2->med_bootstrap->mp_refcount == 0)
- mach_port_put(med2->med_bootstrap);
- if (--med2->med_kernel->mp_refcount == 0)
- mach_port_put(med2->med_kernel);
- if (--med2->med_host->mp_refcount == 0)
- mach_port_put(med2->med_host);
- if (--med2->med_exception->mp_refcount == 0)
- mach_port_put(med2->med_exception);
-
- /*
- * Share ports and rights with the parent, bump their reference
- * counts so that if p2 deallocates some right, p1 is still able
- * to use it.
- */
- med2->med_right = med1->med_right;
- LIST_FOREACH(mr, &med2->med_right, mr_list)
- mr->mr_refcount++;
-
- med2->med_bootstrap->mp_refcount++;
- med2->med_kernel->mp_refcount++;
- med2->med_host->mp_refcount++;
- med2->med_exception->mp_refcount++;
-
- med2->med_bootstrap = med1->med_bootstrap;
- med2->med_kernel = med1->med_kernel;
- med2->med_host = med1->med_host;
- med2->med_exception = med1->med_exception;
-
- return;
-}
diff -r 0d87bbb1b885 -r 568aad545b51 sys/compat/mach/mach_thread.h
--- a/sys/compat/mach/mach_thread.h Sun Jan 26 07:07:31 2003 +0000
+++ b/sys/compat/mach/mach_thread.h Sun Jan 26 12:39:32 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_thread.h,v 1.7 2003/01/21 04:06:08 matt Exp $ */
+/* $NetBSD: mach_thread.h,v 1.8 2003/01/26 12:39:32 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -101,6 +101,5 @@
int mach_thread_policy(struct mach_trap_args *);
int mach_thread_create_running(struct mach_trap_args *);
void mach_create_thread_child(void *);
-void mach_copy_right(struct lwp *, struct lwp *);
#endif /* _MACH_THREAD_H_ */
Home |
Main Index |
Thread Index |
Old Index