summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2004-07-20 20:19:53 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2004-07-20 20:19:53 +0000
commitefbc8ef7df9425ed2171c341c62979657387bfa5 (patch)
tree78137e2a75e7365c57101d32f48992cb0362bdba
parent3007bd7d121c38b72cd0b72b8f749bfc55180df8 (diff)
protect printf with a mutex instead of SIMPLELOCK.
-rw-r--r--sys/kern/init_main.c5
-rw-r--r--sys/kern/subr_prf.c58
2 files changed, 11 insertions, 52 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 25666a6ff45..39f991b9ead 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.117 2004/06/24 19:35:24 tholo Exp $ */
+/* $OpenBSD: init_main.c,v 1.118 2004/07/20 20:19:52 art Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -187,7 +187,6 @@ main(framep)
int s, i;
register_t rval[2];
extern struct pdevinit pdevinit[];
- extern struct SIMPLELOCK kprintf_slock;
extern void scheduler_start(void);
extern void disk_init(void);
extern void endtsleep(void *);
@@ -214,8 +213,6 @@ main(framep)
config_init(); /* init autoconfiguration data structures */
consinit();
- SIMPLE_LOCK_INIT(&kprintf_slock);
-
printf("%s\n", copyright);
KERNEL_LOCK_INIT();
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index a843c2f1dc2..e4d04aa0bc7 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.59 2004/06/13 21:49:26 niklas Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.60 2004/07/20 20:19:52 art Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -47,12 +47,12 @@
#include <sys/ioctl.h>
#include <sys/vnode.h>
#include <sys/file.h>
-#include <sys/simplelock.h>
#include <sys/tty.h>
#include <sys/tprintf.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
#include <sys/pool.h>
+#include <sys/mutex.h>
#include <dev/cons.h>
@@ -98,49 +98,7 @@ extern int uvm_doswapencrypt;
int kprintf(const char *, int, void *, char *, va_list);
void kputchar(int, int, struct tty *);
-#ifdef MULTIPROCESSOR
-
-#ifdef notdef
-
-struct simplelock kprintf_slock;
-
-#define KPRINTF_MUTEX_ENTER(s) \
-do { \
- (s) = splhigh(); \
- simple_lock(&kprintf_slock); \
-} while (/*CONSTCOND*/0)
-
-#define KPRINTF_MUTEX_EXIT(s) \
-do { \
- simple_unlock(&kprintf_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/0)
-
-#else
-
-struct __mp_lock kprintf_slock;
-
-#define KPRINTF_MUTEX_ENTER(s) \
-do { \
- (s) = splhigh(); \
- __mp_lock(&kprintf_slock); \
-} while (/*CONSTCOND*/0)
-
-#define KPRINTF_MUTEX_EXIT(s) \
-do { \
- __mp_unlock(&kprintf_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/0)
-
-#endif
-
-#else
-
-struct simplelock kprintf_slock;
-#define KPRINTF_MUTEX_ENTER(s) (s) = splhigh()
-#define KPRINTF_MUTEX_EXIT(s) splx((s))
-
-#endif /* MULTIPROCESSOR */
+struct mutex kprintf_mutex = MUTEX_INITIALIZER(IPL_HIGH);
/*
* globals
@@ -551,9 +509,8 @@ printf(const char *fmt, ...)
{
va_list ap;
int savintr, retval;
- int s;
- KPRINTF_MUTEX_ENTER(s);
+ mtx_enter(&kprintf_mutex);
savintr = consintr; /* disable interrupts */
consintr = 0;
@@ -564,7 +521,7 @@ printf(const char *fmt, ...)
logwakeup();
consintr = savintr; /* reenable interrupts */
- KPRINTF_MUTEX_EXIT(s);
+ mtx_leave(&kprintf_mutex);
return(retval);
}
@@ -579,12 +536,17 @@ vprintf(const char *fmt, va_list ap)
{
int savintr, retval;
+ mtx_enter(&kprintf_mutex);
+
savintr = consintr; /* disable interrupts */
consintr = 0;
retval = kprintf(fmt, TOCONS | TOLOG, NULL, NULL, ap);
if (!panicstr)
logwakeup();
consintr = savintr; /* reenable interrupts */
+
+ mtx_leave(&kprintf_mutex);
+
return (retval);
}