A spinlock augmented with safety checks for use with SPDK. More...
#include <thread.h>
Data Fields | |
pthread_spinlock_t | spinlock |
struct spdk_thread * | thread |
struct spdk_spinlock_internal * | internal |
bool | initialized |
bool | destroyed |
A spinlock augmented with safety checks for use with SPDK.
SPDK code that uses spdk_spinlock runs from an SPDK thread, which itself is associated with a pthread. There are typically many SPDK threads associated with each pthread. The SPDK application may migrate SPDK threads between pthreads from time to time to balance the load on those threads. Migration of SPDK threads only happens when the thread is off CPU, and as such it is only safe to hold a lock so long as an SPDK thread stays on CPU.
It is not safe to lock a spinlock, return from the event or poller, then unlock it at some later time because:
If an SPDK spinlock is used erroneously, the program will abort.