Tag: atomics

  • Using atomics for thread synchronization in C++

    In my previous blog post I wrote about spin locks, and how compilers must not move the locking loop above a prior unlock. After thinking about this done more, I realised that is not something specific to locks — the same issue arises with any two…

  • Can non-overlapping spinlocks deadlock in C++?

    There has been discussion on Twitter recently about whether or not the C++ memory model allows spinlocks to deadlock if they just use memory_order_acquire in lock and memory_order_release in unlock, due to compiler optimizations. The case in question i…