Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys lwp0 seems like an lwp instead of a process, so move bit...
details: https://anonhg.NetBSD.org/src/rev/550c64443253
branches: trunk
changeset: 755591:550c64443253
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Jun 10 20:54:53 2010 +0000
description:
lwp0 seems like an lwp instead of a process, so move bits related
to it from kern_proc.c to kern_lwp.c. This makes kern_proc
"scheduling-clean" and more easily usable in environments with a
non-integrated scheduler (like, to take a random example, rump).
diffstat:
sys/kern/init_main.c | 6 +++---
sys/kern/kern_lwp.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
sys/kern/kern_proc.c | 41 +++--------------------------------------
sys/sys/lwp.h | 3 ++-
4 files changed, 53 insertions(+), 44 deletions(-)
diffs (234 lines):
diff -r efd67e6d75fe -r 550c64443253 sys/kern/init_main.c
--- a/sys/kern/init_main.c Thu Jun 10 20:36:55 2010 +0000
+++ b/sys/kern/init_main.c Thu Jun 10 20:54:53 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.419 2010/04/21 16:51:24 pooka Exp $ */
+/* $NetBSD: init_main.c,v 1.420 2010/06/10 20:54:53 pooka Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.419 2010/04/21 16:51:24 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.420 2010/06/10 20:54:53 pooka Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -247,7 +247,6 @@
#include <sys/userconf.h>
#endif
-extern struct proc proc0;
extern struct lwp lwp0;
extern time_t rootfstime;
@@ -387,6 +386,7 @@
/* Create process 0. */
proc0_init();
+ lwp0_init();
/* Disable preemption during boot. */
kpreempt_disable();
diff -r efd67e6d75fe -r 550c64443253 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c Thu Jun 10 20:36:55 2010 +0000
+++ b/sys/kern/kern_lwp.c Thu Jun 10 20:54:53 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lwp.c,v 1.146 2010/04/23 19:18:09 rmind Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.147 2010/06/10 20:54:53 pooka Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -209,7 +209,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.146 2010/04/23 19:18:09 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.147 2010/06/10 20:54:53 pooka Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -259,6 +259,27 @@
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
+struct turnstile turnstile0;
+struct lwp lwp0 __aligned(MIN_LWP_ALIGNMENT) = {
+#ifdef LWP0_CPU_INFO
+ .l_cpu = LWP0_CPU_INFO,
+#endif
+ .l_proc = &proc0,
+ .l_lid = 1,
+ .l_flag = LW_SYSTEM,
+ .l_stat = LSONPROC,
+ .l_ts = &turnstile0,
+ .l_syncobj = &sched_syncobj,
+ .l_refcnt = 1,
+ .l_priority = PRI_USER + NPRI_USER - 1,
+ .l_inheritedprio = -1,
+ .l_class = SCHED_OTHER,
+ .l_psid = PS_NONE,
+ .l_pi_lenders = SLIST_HEAD_INITIALIZER(&lwp0.l_pi_lenders),
+ .l_name = __UNCONST("swapper"),
+ .l_fd = &filedesc0,
+};
+
void
lwpinit(void)
{
@@ -269,6 +290,28 @@
"lwppl", NULL, IPL_NONE, NULL, NULL, NULL);
}
+void
+lwp0_init(void)
+{
+ struct lwp *l = &lwp0;
+
+ KASSERT((void *)uvm_lwp_getuarea(l) != NULL);
+ KASSERT(l->l_lid == p->p_nlwpid);
+
+ LIST_INSERT_HEAD(&alllwp, l, l_list);
+
+ callout_init(&l->l_timeout_ch, CALLOUT_MPSAFE);
+ callout_setfunc(&l->l_timeout_ch, sleepq_timeout, l);
+ cv_init(&l->l_sigcv, "sigwait");
+
+ kauth_cred_hold(proc0.p_cred);
+ l->l_cred = proc0.p_cred;
+
+ lwp_initspecific(l);
+
+ SYSCALL_TIME_LWP_INIT(l);
+}
+
/*
* Set an suspended.
*
diff -r efd67e6d75fe -r 550c64443253 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Thu Jun 10 20:36:55 2010 +0000
+++ b/sys/kern/kern_proc.c Thu Jun 10 20:54:53 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.165 2010/06/10 19:06:26 pooka Exp $ */
+/* $NetBSD: kern_proc.c,v 1.166 2010/06/10 20:54:53 pooka Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.165 2010/06/10 19:06:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.166 2010/06/10 20:54:53 pooka Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -166,7 +166,6 @@
struct pstats pstat0;
struct vmspace vmspace0;
struct sigacts sigacts0;
-struct turnstile turnstile0;
struct proc proc0 = {
.p_lwps = LIST_HEAD_INITIALIZER(&proc0.p_lwps),
.p_sigwaiters = LIST_HEAD_INITIALIZER(&proc0.p_sigwaiters),
@@ -190,25 +189,6 @@
.p_stats = &pstat0,
.p_sigacts = &sigacts0,
};
-struct lwp lwp0 __aligned(MIN_LWP_ALIGNMENT) = {
-#ifdef LWP0_CPU_INFO
- .l_cpu = LWP0_CPU_INFO,
-#endif
- .l_proc = &proc0,
- .l_lid = 1,
- .l_flag = LW_SYSTEM,
- .l_stat = LSONPROC,
- .l_ts = &turnstile0,
- .l_syncobj = &sched_syncobj,
- .l_refcnt = 1,
- .l_priority = PRI_USER + NPRI_USER - 1,
- .l_inheritedprio = -1,
- .l_class = SCHED_OTHER,
- .l_psid = PS_NONE,
- .l_pi_lenders = SLIST_HEAD_INITIALIZER(&lwp0.l_pi_lenders),
- .l_name = __UNCONST("swapper"),
- .l_fd = &filedesc0,
-};
kauth_cred_t cred0;
int nofile = NOFILE;
@@ -361,16 +341,11 @@
{
struct proc *p;
struct pgrp *pg;
- struct lwp *l;
rlim_t lim;
int i;
p = &proc0;
pg = &pgrp0;
- l = &lwp0;
-
- KASSERT((void *)uvm_lwp_getuarea(l) != NULL);
- KASSERT(l->l_lid == p->p_nlwpid);
mutex_init(&p->p_stmutex, MUTEX_DEFAULT, IPL_HIGH);
mutex_init(&p->p_auxlock, MUTEX_DEFAULT, IPL_NONE);
@@ -380,11 +355,10 @@
cv_init(&p->p_waitcv, "wait");
cv_init(&p->p_lwpcv, "lwpwait");
- LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling);
+ LIST_INSERT_HEAD(&p->p_lwps, &lwp0, l_sibling);
pid_table[0].pt_proc = p;
LIST_INSERT_HEAD(&allproc, p, p_list);
- LIST_INSERT_HEAD(&alllwp, l, l_list);
pid_table[0].pt_pgrp = pg;
LIST_INSERT_HEAD(&pg->pg_members, p, p_pglist);
@@ -393,15 +367,9 @@
(*p->p_emul->e_syscall_intern)(p);
#endif
- callout_init(&l->l_timeout_ch, CALLOUT_MPSAFE);
- callout_setfunc(&l->l_timeout_ch, sleepq_timeout, l);
- cv_init(&l->l_sigcv, "sigwait");
-
/* Create credentials. */
cred0 = kauth_cred_alloc();
p->p_cred = cred0;
- kauth_cred_hold(cred0);
- l->l_cred = cred0;
/* Create the CWD info. */
rw_init(&cwdi0.cwdi_lock);
@@ -448,9 +416,6 @@
proc_initspecific(p);
kdtrace_proc_ctor(NULL, p);
- lwp_initspecific(l);
-
- SYSCALL_TIME_LWP_INIT(l);
}
/*
diff -r efd67e6d75fe -r 550c64443253 sys/sys/lwp.h
--- a/sys/sys/lwp.h Thu Jun 10 20:36:55 2010 +0000
+++ b/sys/sys/lwp.h Thu Jun 10 20:54:53 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.133 2010/05/30 02:25:15 dholland Exp $ */
+/* $NetBSD: lwp.h,v 1.134 2010/06/10 20:54:53 pooka Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010
@@ -305,6 +305,7 @@
/* Flags for _lwp_wait1 */
#define LWPWAIT_EXITCONTROL 0x00000001
void lwpinit(void);
+void lwp0_init(void);
int lwp_wait1(lwp_t *, lwpid_t, lwpid_t *, int);
void lwp_continue(lwp_t *);
void lwp_unstop(lwp_t *);
Home |
Main Index |
Thread Index |
Old Index