Source-Changes-HG archive

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

[src/trunk]: src/sys/dev solve the race condition while output for umidi.



details:   https://anonhg.NetBSD.org/src/rev/1bd2c3d008ba
branches:  trunk
changeset: 503101:1bd2c3d008ba
user:      tshiozak <tshiozak%NetBSD.org@localhost>
date:      Wed Jan 31 16:19:35 2001 +0000

description:
solve the race condition while output for umidi.

diffstat:

 sys/dev/midi.c |  25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diffs (50 lines):

diff -r bf9b2c905e1f -r 1bd2c3d008ba sys/dev/midi.c
--- a/sys/dev/midi.c    Wed Jan 31 16:02:38 2001 +0000
+++ b/sys/dev/midi.c    Wed Jan 31 16:19:35 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midi.c,v 1.20 2001/01/30 23:02:18 tshiozak Exp $       */
+/*     $NetBSD: midi.c,v 1.21 2001/01/31 16:19:35 tshiozak Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -543,7 +543,7 @@
        int intr;
 {
        struct midi_buffer *mb = &sc->outbuf;
-       u_char *outp;
+       u_char out;
        int error;
        int s;
        int i;
@@ -560,21 +560,20 @@
        sc->pbus = (mb->used > 0)?1:0;
        for (i = 0; i < MIDI_MAX_WRITE && mb->used > 0 &&
                   (!error || error==EINPROGRESS); i++) {
-               outp = mb->outp;
-               DPRINTFN(4, ("midi_start_output: %p i=%d, data=0x%02x\n", 
-                            sc, i, *outp));
-               error = sc->hw_if->output(sc->hw_hdl, *outp);
                s = splaudio();
-               outp++;
+               out = *mb->outp;
+               mb->outp++;
+               if (mb->outp >= mb->end)
+                       mb->outp = mb->start;
+               mb->used--;
+               splx(s);
 #ifdef MIDI_SAVE
-               midisave.buf[midicnt] = *outp;
+               midisave.buf[midicnt] = out;
                midicnt = (midicnt + 1) % MIDI_SAVE_SIZE;
 #endif
-               if (outp >= mb->end)
-                       outp = mb->start;
-               mb->outp = outp;
-               mb->used--;
-               splx(s);
+               DPRINTFN(4, ("midi_start_output: %p i=%d, data=0x%02x\n", 
+                            sc, i, out));
+               error = sc->hw_if->output(sc->hw_hdl, out);
                if ((sc->props & MIDI_PROP_OUT_INTR) && error!=EINPROGRESS)
                        /* If ointr is enabled, midi_start_output()
                         * normally writes only one byte,



Home | Main Index | Thread Index | Old Index