Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jan 1998 09:19:04 -0300
From:      daniel_sobral@voga.com.br
To:        hackers@FreeBSD.ORG
Subject:   Re: uiomove()
Message-ID:  <83256595.0043094E.00@papagaio.voga.com.br>

next in thread | raw e-mail | index | archive | help

> look at /sys/i386/isa/snd/dmabuf.c how i handle a circular buffer.

Ok, I gave it a look. I'm still not completely sure about what I should do
in some situations. Please excuse me if I sound asleep, that's the way I
feel actually. In fact, I'm pretty much sure I must be sleepwalking. :-)

Ok, so here is the deal. Since this is an encryption card, what I do is
write each character to the card and then read the encrypted character
back. So, write() writes the data to a circular buffer, and read() reads
from a circular buffer.

I'm using a single circular buffer, with three pointers: last character
written (+1), first character to be read, and next character to be
encrypted/decrypted. Write() is very simple, indeed. After writing data to
the buffer, it timeout()s a function which will be doing the conversion.

The read() function is the source of most of my doubts.

As long as enough data has been written to the buffer, the read() function
will wait until the function doing the conversion (crypt()) en/decrypts
enough characters.

So, read() is tsleeping on PZERO priority, so crypt() can be called. Now,
there is a few race windows. First, if read() and write() are called
simultaneously and one of them preempts the other, there might be a race
window. I don't know if one of them can preempt another or not. Another
race window happens between read() and crypt(). That one seems easier to
get rid of, but spl0() is not what I want, since I cannot splx() after
that. It seems splsoft*() is what I want, but I don't know which.
Splitting read and write buffers would eliminate the race between read()
and write(), and introduce a race between write() and crypt(), which may be
helpful.

Anyone wants to enlight me?

--
Daniel C. Sobral                      (8-DCS)
Daniel_Sobral@voga.com.br


Tagline:
   * FreeBSD. Earth.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?83256595.0043094E.00>