April 2012
Intermediate to advanced
352 pages
8h
English
Example 4-4 is a revision of Example 4-3 that uses an sx lock instead of a mutex.
To save space, the functions race_ioctl, race_new, race_find, and race_destroy aren’t listed here, as they haven’t been changed.
Example 4-4. race_sx.c
#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/uio.h> #include <sys/malloc.h> #include <sys/ioccom.h> #include <sys/queue.h> #include <sys/lock.h>#include <sys/sx.h> #include "race_ioctl.h" MALLOC_DEFINE(M_RACE, "race", "race object"); struct race_softc { LIST_ENTRY(race_softc) list; int unit; }; ...