Skip to content

Commit

Permalink
Added comments referencing spin-lock lock/unlock read/writes (#1501)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJake222 authored May 19, 2024
1 parent 7d238ea commit 3f41d7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rp2_common/hardware_sync/include/hardware/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ __force_inline static void spin_lock_unsafe_blocking(spin_lock_t *lock) {
// Note we don't do a wfe or anything, because by convention these spin_locks are VERY SHORT LIVED and NEVER BLOCK and run
// with INTERRUPTS disabled (to ensure that)... therefore nothing on our core could be blocking us, so we just need to wait on another core
// anyway which should be finished soon
while (__builtin_expect(!*lock, 0)) {
while (__builtin_expect(!*lock, 0)) { // read from spinlock register (tries to acquire the lock)
tight_loop_contents();
}
__mem_fence_acquire();
Expand All @@ -275,7 +275,7 @@ __force_inline static void spin_lock_unsafe_blocking(spin_lock_t *lock) {
*/
__force_inline static void spin_unlock_unsafe(spin_lock_t *lock) {
__mem_fence_release();
*lock = 0;
*lock = 0; // write to spinlock register (release lock)
}

/*! \brief Acquire a spin lock safely
Expand Down

0 comments on commit 3f41d7d

Please sign in to comment.