Writing Device Drivers

Using Mutexes

Every section of the driver code that needs to read or write the shared data structure must do the following:

The scope of a mutex--the data it protects--is entirely up to the programmer. A mutex protects some particular data structure because the programmer chooses to do so and uses it accordingly. A mutex protects a data structure only if every code path that accesses the data structure does so while holding the mutex.