In the Mutex or spinlock? Which to use when section, you learned when to use the spinlock instead of the mutex lock and vice versa. For convenience, we have reproduced the key statements we provided previously here:
- Is the critical section running in an atomic (interrupt) context or in a process context where it cannot sleep? Use the spinlock.
- Is the critical section running in a process context and sleep in the critical section is necessary? Use the mutex lock.
In this section, we shall consider that you've now decided to use the spinlock.