Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Use real atomics, not atomics faked with membars, f...



details:   https://anonhg.NetBSD.org/src/rev/5bb8953d597f
branches:  trunk
changeset: 343621:5bb8953d597f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 17 01:09:49 2016 +0000

description:
Use real atomics, not atomics faked with membars, for rnd_printing.

diffstat:

 sys/kern/kern_rndq.c |  12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diffs (41 lines):

diff -r 0c618ed38e56 -r 5bb8953d597f sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Wed Feb 17 01:01:42 2016 +0000
+++ b/sys/kern/kern_rndq.c      Wed Feb 17 01:09:49 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndq.c,v 1.78 2016/02/17 01:01:42 riastradh Exp $ */
+/*     $NetBSD: kern_rndq.c,v 1.79 2016/02/17 01:09:49 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.78 2016/02/17 01:01:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.79 2016/02/17 01:09:49 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -162,7 +162,7 @@
 int                    rnd_ready = 0;
 int                    rnd_initial_entropy = 0;
 
-static int             rnd_printing = 0;
+static volatile unsigned       rnd_printing = 0;
 
 #ifdef DIAGNOSTIC
 static int             rnd_tested = 0;
@@ -177,12 +177,8 @@
 {
        va_list ap;
 
-       membar_consumer();
-       if (rnd_printing) {
+       if (atomic_cas_uint(&rnd_printing, 0, 1) != 0)
                return;
-       }
-       rnd_printing = 1;
-       membar_producer();
        va_start(ap, fmt);
        vprintf(fmt, ap);
        va_end(ap);



Home | Main Index | Thread Index | Old Index