wait-free

Anything in std::atomic is wait-free?

狂风中的少年 提交于 2020-08-24 08:09:29
问题 If T is a C++ fundamental type, and if std::atomic<T>::is_lock_free() returns true , then is there anything in std::atomic<T> that is wait-free (not just lock-free)? Like, load , store , fetch_add , fetch_sub , compare_exchange_weak , and compare_exchange_strong . Can you also answer based on what is specified in the C++ Standard, and what is implemented in Clang and/or GCC (your version of choice). My favorite definitions for lock-free and wait-free are taken from C++ Concurrency in Action

Are X86 atomic RMW instructions wait free

社会主义新天地 提交于 2020-07-21 03:42:32
问题 On x86, atomic RMW instructions like lock add dword [rdi], 1 are implemented using cache locking on modern CPUs. So a cache line is locked for duration of the instruction. This is done by getting the line EXCLUSIVE/MODIFIED state when value is read and the CPU will not respond to MESI requests from other CPU's until the instruction is finished. There are 2 flavors of concurrent progress conditions, blocking and non-blocking. Atomic RMW instructions are non-blocking. CPU hardware will never

Are X86 atomic RMW instructions wait free

隐身守侯 提交于 2020-07-21 03:40:46
问题 On x86, atomic RMW instructions like lock add dword [rdi], 1 are implemented using cache locking on modern CPUs. So a cache line is locked for duration of the instruction. This is done by getting the line EXCLUSIVE/MODIFIED state when value is read and the CPU will not respond to MESI requests from other CPU's until the instruction is finished. There are 2 flavors of concurrent progress conditions, blocking and non-blocking. Atomic RMW instructions are non-blocking. CPU hardware will never