This reverts commit bb52288561.
Event though this fixes a deadlock in the new protocol, it
actually breaks fair locking as one side could lock multiple
times in a row.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Clear the thread ID to 0 when unlocking the mutex to prevent deadlock.
If the thread holding never reacquire it, other threads would be
permanently blocked with a stale thread ID.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Use C11 atomic operations to implement the mutex instead
of hard-coded intrinsics. This generates more efficient
assembly on newer ARM architectures by taking advantage
of the new LDA/STL instructions (and their exclusive variants),
which avoid full memory barriers while still providing
memory ordering guarantees.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>