3 ms·
This would rely on an atomic update of the write index surely - is this guaranteed?
by thebruce87m 8y ago
This would rely on an atomic update of the write index surely - is this guaranteed?
- learc83 8y agoYes most lock free thread safe paterns require the use of some atomic instructions. In the context of embeded real time systems you are generally targeting specific hardware, so you can make gurantees about the atomicity of specific instructions.
- tlb 8y agoThe requirement is generally that it can be written in a single instruction. This can fail on 32-bit processors like the x86 if you use a 64-bit index. For embedded work, it can fail on 8-bit processors if you use a 16-bit index. You can check, in C++, whether operations on a type are a single instruction. This might be true on an x84_64 and false on an x86: std::atomic<int64_t>::is_lock_free()