In our simple demo misc character device driver program's (miscdrv_rdwr/miscdrv_rdwr.c) open method (and elsewhere), we defined and manipulated two static global integers, ga and gb:
static int ga, gb = 1;
[...]
ga++; gb--;
By now, it should be obvious to you that this – the place where we operate on these integers – is a potential bug if left as is: it's shared writable data (in a shared state) and therefore a critical section, thus requiring protection against concurrent access. You get it; so, we progressively improved upon this. In the previous chapter, understanding the issue, in our ch12/1_miscdrv_rdwr_mutexlock/1_miscdrv_rdwr_mutexlock.c program, we first used a mutex lock to protect the critical section. Later, you learned that using a spinlock to protect non-blocking critical sections such as this one would be (far) superior to using a mutex in terms of performance; so, in our next driver,...