🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
3 messages
3 total messages Started by Graham Stoney Mon, 12 Oct 1992 11:02
Implementing select() in an asynchronous device driver. Impossible!
#1441
Author: Graham Stoney
Date: Mon, 12 Oct 1992 11:02
21 lines
1616 bytes
I'm having great difficulty writing an asynchronous Unix style device driver
running under BSD/Mach/NeXTStep. Are there any asynchronous device driver
authors out there that could help me please?. There's zippo documentation on
how to do this in NeXT's "Writing Loadable Kernel Servers" manual, and it's
proving very difficult.

In particular, implementing select() for the driver is a nightmare; the
"selwakeup" kernel function is undocumented, and it's operation is different
to the same function on other BSDish systems, such as a Sun. The only example
code I can find is from the Sun device driver manual, and it appears to have a
race condition where the driver could get an interrupt between when the
driver's xxselect returns false and the kernel puts the process to sleep;
causing the process to hang since it's already missed the chance to selwakeup.

Egan and Teixeira's "Writing a UNIX Device Driver" doesn't even come close to
describing an asynchronous driver.

Is there any hope for me?.

Any help would be greatly appreciated,
Graham
Re: Implementing select() in an asynchronous device driver. Impossible!
#1486
Author: Bruce Momjian
Date: Mon, 12 Oct 1992 20:20
10 lines
999 bytes
I have just posted to comp.sources.misc 'pol', a poll()/select() device
driver for SysV machines.  

It may be of some help.  Keep an eye out for it.

-- 
Bruce Momjian                          |  830 Blythe Avenue
root%candle.uucp@bts.com               |  Drexel Hill, Pennsylvania 19026 
  +  If your life is a hard drive,     |  (215) 353-9879(w) 
  +  Christ can be your backup.        |  (215) 853-3000(h)
Re: Implementing select() in an asynchronous device driver. Impossible!
#1475
Author: Graham Stoney
Date: Wed, 14 Oct 1992 05:40
33 lines
2454 bytes
In a previous article, I rambled incoherently:
>I'm having great difficulty writing an asynchronous Unix style device driver
>running under BSD/Mach/NeXTStep. Are there any asynchronous device driver
>authors out there that could help me please?. There's zippo documentation on
>how to do this in NeXT's "Writing Loadable Kernel Servers" manual, and it's
>proving very difficult.

>In particular, implementing select() for the driver is a nightmare; the
>"selwakeup" kernel function is undocumented, and it's operation is different
>to the same function on other BSDish systems, such as a Sun. The only example
>code I can find is from the Sun device driver manual, and it appears to have a
>race condition where the driver could get an interrupt between when the
>driver's xxselect returns false and the kernel puts the process to sleep;
>causing the process to hang since it's already missed the chance to selwakeup.

As you can see, I was deeply frustrated, and certainly not in a fit state to be
posting when I posted this. The problem is with a NeXT machine, and this
probably has a target audience of approximately (or at least very close to)
zero, but I've found the solution, so I'm going to post it anyway.

The problem, which I diagnosed by the ancient art of kernel disassembly, is
that selwakeup (and also wakeup, which I was using elsewhere too) ultimately
calls thread_wakeup, and the NeXT A"Writing Loadable Kernel Servers" manual
states that thread_wakeup can't be called at interrupt priorities greater than
3. Since our server handles NeXTbus interrupts at ipl5, I was doing the wrong
thing, and suffering kernel panics and lockups for it.

The solution is to use kern_serv_callout to call selwakeup and wakeup.

>Is there any hope for me?.
So, there is a tiny ray of hope... just.

Graham
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads