From owner-freebsd-hackers Fri Jan 23 03:18:48 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA21514 for hackers-outgoing; Fri, 23 Jan 1998 03:18:48 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from db2server.voga.com.br (db2server.voga.com.br [200.239.39.7]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA21508 for ; Fri, 23 Jan 1998 03:18:41 -0800 (PST) (envelope-from daniel_sobral@voga.com.br) From: daniel_sobral@voga.com.br Received: from papagaio.voga.com.br (papagaio.voga.com.br [200.239.39.2]) by db2server.voga.com.br (8.8.3+2.6Wbeta9/8.8.7) with SMTP id JAA17044 for ; Fri, 23 Jan 1998 09:19:14 -0200 Received: by papagaio.voga.com.br(Lotus SMTP MTA v1.06 (346.7 3-18-1997)) id 03256595.0043ABAB ; Fri, 23 Jan 1998 09:19:08 -0300 X-Lotus-FromDomain: VOGA To: hackers@FreeBSD.ORG Message-ID: <83256595.0043094E.00@papagaio.voga.com.br> Date: Fri, 23 Jan 1998 09:19:04 -0300 Subject: Re: uiomove() Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk > 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.