Writing Device Drivers

Using Task Queues

The typical usage in drivers is to create task queues at attach(9E). Most taskq_dispatch() invocations are from interrupt context.

To study task queues used in Solaris drivers, go to http://hub.opensolaris.org/bin/view/Main/. In the upper right corner, click Source Browser. In the Symbol field of the search area, enter ddi_taskq_create. In the File Path field, enter amr.In the Project list, select onnv. Click the Search button. In your search results you should see the SCSI HBA driver for Dell PERC 3DC/4SC/4DC/4Di RAID devices (amr.c).

Click the file name amr.c. The ddi_taskq_create() function is called in the amr_attach() entry point. The ddi_taskq_destroy() function is called in the amr_detach() entry point and also in the error handling section of the amr_attach() entry point. The ddi_taskq_dispatch() function is called in the amr_done() function, which is called in the amr_intr() function. The amr_intr() function is an interrupt-handling function that is an argument to the ddi_add_intr(9F) function in the amr_attach() entry point.