summaryrefslogtreecommitdiff
path: root/sys/kern/subr_prf.c
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 /sys/kern/subr_prf.c
parent3007bd7d121c38b72cd0b72b8f749bfc55180df8 (diff)
protect printf with a mutex instead of SIMPLELOCK.
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r--sys/kern/subr_prf.c58
1 files changed, 10 insertions, 48 deletions
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);
}