[comp.unix.wizards] How do I implement asynchronous driver that works under sunview

roderic@vicom.com (Roderic Taylor) (06/28/90)

(SunOS 4.03, Sparcstation)

   I'm trying to get a simple driver I've written (read only) to work
with Sunview.  I open the driver and call notify_set_input_func() with
the appropriate arguments, but the notifier only calls the event handler
occasionally (when the mouse is moved); it does not call it as new data
comes in from the device.
   Following the advice from the Sun manual, "Writing Device Drivers"
(section 6.9-Skeleton Driver Variations, "Asynchronous I/O support"),
I've written a simple driver select function and have created a mechanism
using ioctl() to direct the driver to generate SIGIO interrupts when new
data arrives.  I've tested both these features outside the notifier, and
they work.
   I'm presuming the notifier works by getting the device to generate
SIGIO interrupts (though I'm not sure this is the case).  Perhaps
there is some standard mechanism I've missed that enables SIGIO on a
file descriptor and needs to be supported in the driver code somehow.
The method of using ioctl() to turn on and off SIGIO given in
"Writing Device Drivers" doesn't look like a general interface.
It mentions that fcntl() can also be used to implement asynchronous
IO control, but doesn't mention what (if anything) must be put
in the driver for it to work.  I've tried enabling the driver's
SIGIO feature myself (using my ioctl command) before entering the
notifier loop, but that doesn't help.

                                                      --Roderic T

roderic@vicom.com (Roderic Taylor) (06/30/90)

[ In a recent message, I said I was having trouble with a Sunview ]
[ event handler reading input asynchronously from a driver I'd    ]
[ written.  I had implemented SIGIO for the driver, but assumed   ]
[ I needed to do it in a more standard manner that SunView can    ]
[ manipulate.                                                     ]

   As a number of people have pointed out to me, SunView does
not implement event handlers through signal catchers, but rather
through a select() command that blocks until input comes in on
any of the file descriptors the notifier expects input from.
My driver did not call selwakeup() in its interrupt routine (which
wakes up proceses blocked on select), and that was the problem.
Many thanks to all those who took the time to reply.


                                                     --Roderic T