A More Complex Synchronization Problem
Example 4-1 is a complete character driver that lets you manipulate a doubly linked list through its d_ioctl
function. You can add or remove an item from the list, determine whether an item is on the list, or print every item on the list. Example 4-1 also contains some synchronization problems.
Note
Take a quick look at this code and try to identify the synchronization problems.
Example 4-1. race.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 "race_ioctl.h" MALLOC_DEFINE(M_RACE, "race", "race object"); struct race_softc { LIST_ENTRY(race_softc) ...
Get FreeBSD Device Drivers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.