doc: mention SPDK spinlocks in concurrency.md

Encourage the use of spdk_spinlock over pthread_mutex_t and
pthread_spinlock_t to improve safety and debugability.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I22e2d3cc917687c9878d7558fe8c640051b51a45
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16021
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Mike Gerdts 2022-12-19 12:03:56 -06:00 committed by Tomasz Zawadzki
parent ed4b89aaab
commit b09ae853f9

View File

@ -110,6 +110,18 @@ repeatedly call `spdk_thread_poll()` on each `spdk_thread()` that exists. This
makes SPDK very portable to a wide variety of asynchronous, event-based makes SPDK very portable to a wide variety of asynchronous, event-based
frameworks such as [Seastar](https://www.seastar.io) or [libuv](https://libuv.org/). frameworks such as [Seastar](https://www.seastar.io) or [libuv](https://libuv.org/).
## SPDK Spinlocks
There are some cases where locks are used. These should be limited in favor of
the message passing interface described above. When locks are needed,
SPDK spinlocks should be used instead of POSIX locks.
POSIX locks like `pthread_mutex_t` and `pthread_spinlock_t` do not properly
handle locking between SPDK's lightweight threads. SPDK's `spdk_spinlock`
is safe to use in SPDK libraries and applications. This safety comes from
imposing restrictions on when locks can be held. See
[spdk_spinlock](structspdk__spinlock.html) for details.
## The event Framework ## The event Framework
The SPDK project didn't want to officially pick an asynchronous, event-based The SPDK project didn't want to officially pick an asynchronous, event-based