|
MINIX Kernel Documentation
|
Structure representing a simple spinlock. More...
#include <k_spinlock.h>
Public Attributes | |
| volatile int | locked |
| The lock state. 0 for unlocked, 1 for locked. | |
| unsigned long | acquisitions |
| Number of times the lock was successfully acquired. | |
| unsigned long | contentions |
| Number of times a thread tried to acquire the lock but found it already held, thus entering a spin-wait loop. This indicates contention. | |
Structure representing a simple spinlock.
The spinlock's state is determined by the locked member. It also includes basic statistics for acquisitions and contentions. It is crucial that operations on this structure use the provided simple_spin_* functions to ensure atomicity and correct memory ordering.
| unsigned long simple_spinlock_t::acquisitions |
Number of times the lock was successfully acquired.
| unsigned long simple_spinlock_t::contentions |
Number of times a thread tried to acquire the lock but found it already held, thus entering a spin-wait loop. This indicates contention.
| volatile int simple_spinlock_t::locked |
The lock state. 0 for unlocked, 1 for locked.
volatile ensures that the compiler does not optimize away reads of this variable, as its value can change unexpectedly due to actions from other CPUs or threads. The atomicity of lock operations is guaranteed by GCC's __sync_* builtins, not by volatile itself.