summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-05-14 18:47:57 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-05-14 18:47:57 +0000
commit4a681c84c73ea5f06e3780a9e28c9b51e9903df4 (patch)
treeca9123edefe7b1d9556cfd9ad8eadcf14ea4033c
parentf0dfa83de5ced9acad0d97b94b99cde7124e85da (diff)
Make sure we initialize sched_lock before we try to use it.
ok miod@, thib@, oga@, jsing@
-rw-r--r--sys/kern/init_main.c3
-rw-r--r--sys/kern/kern_sched.c5
-rw-r--r--sys/sys/sched.h6
3 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 3f63d3d9cfa..9d7601dbcae 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.166 2010/01/12 04:06:26 deraadt Exp $ */
+/* $OpenBSD: init_main.c,v 1.167 2010/05/14 18:47:56 kettenis Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -216,6 +216,7 @@ main(void *framep)
printf("%s\n", copyright);
KERNEL_LOCK_INIT();
+ SCHED_LOCK_INIT();
uvm_init();
disk_init(); /* must come before autoconfiguration */
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index ffb6285e065..3bee9d98f0c 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.19 2010/04/23 21:34:38 deraadt Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.20 2010/05/14 18:47:56 kettenis Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -200,9 +200,6 @@ sched_exit(struct proc *p)
void
sched_init_runqueues(void)
{
-#ifdef MULTIPROCESSOR
- __mp_lock_init(&sched_lock);
-#endif
}
void
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 9f4f5329781..f54e4e88aa6 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.27 2010/04/23 03:50:22 miod Exp $ */
+/* $OpenBSD: sched.h,v 1.28 2010/05/14 18:47:56 kettenis Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -185,6 +185,8 @@ extern struct __mp_lock sched_lock;
#define SCHED_ASSERT_LOCKED() KASSERT(__mp_lock_held(&sched_lock))
#define SCHED_ASSERT_UNLOCKED() KASSERT(__mp_lock_held(&sched_lock) == 0)
+#define SCHED_LOCK_INIT() __mp_lock_init(&sched_lock)
+
#define SCHED_LOCK(s) \
do { \
s = splsched(); \
@@ -202,6 +204,8 @@ do { \
#define SCHED_ASSERT_LOCKED() splassert(IPL_SCHED);
#define SCHED_ASSERT_UNLOCKED() /* nothing */
+#define SCHED_LOCK_INIT() /* nothing */
+
#define SCHED_LOCK(s) s = splsched()
#define SCHED_UNLOCK(s) splx(s)