Replies: 3 comments
-
@halayli which architecture are you getting the spinlock crash? I think memory order should not be an issue for x86/x86_64. For |
Beta Was this translation helpful? Give feedback.
-
@ThomsonTan the crash happened on a I understand the pthread limitation. It definitely make things more challenging. |
Beta Was this translation helpful? Give feedback.
-
The usage of Here is my understanding: |
Beta Was this translation helpful? Give feedback.
-
I hit a segfault that was pointing to the static
SpinLockMutex
variable.I am not sure it's a good idea to implement a SpinLockMutex in a project like this one. Aside from getting it right on various architectures, the chances of getting it right aren't on your side.
Looking at
try_lock
implementation:It looks suspicious to me, and as far as I can tell by looking at it, is that
!flag_.load(std::memory_order_relaxed)
should be followed byflag_.compare_exchange_weak(...,std::memory_order_acquire, std::memory_order_relaxed)
rather thanflag_.exchange()
I suggest to use
pthread_spin_lock(3)
and friends or a mutex. Just my 2c.Beta Was this translation helpful? Give feedback.
All reactions