Questions tagged [atomic]
An atomic operation is one which can be considered, from the perspective of the computing context in which it occurs, to be executed in a single step. Atomic operations either succeed entirely or fail, with no intermediate states.
64
questions
4
votes
3
answers
518
views
C11 zero copy lock-free triple buffer
The code is for a single producer, single consumer scenario, where the consumer only cares about the latest information shared by the producer.
This is just a simple proof of concept created for linux....
0
votes
1
answer
144
views
C++ slim condition notifier
When writing multi-threading code, one often need the thread to wait for some condition being met. A naive approach would look like this:
...
1
vote
1
answer
323
views
Lock Guard Atomic alternative
I've recently written a Vulkan library for creating 2D applications with ease. The catch was I need std::lock_guard for my window resize event to resize resources ...
1
vote
1
answer
152
views
Implementation of a lock free queue using CompareAndSwap in Go
Here is my implementation of a lock free queue using CompareAndSwap operation.
...
3
votes
2
answers
293
views
atomic spinlock mutex class
This here is the follow-up to this question. I was recommended to implement a Lockable type (similar to std::mutex) that can work with ...
8
votes
3
answers
2k
views
Basic RAII spinlock class
I have written the following class that acts as a simple lock for mutual exclusion:
...
1
vote
1
answer
203
views
Lock-free implementation of getAndUpdate() using atomic CAS (Compare-And-Swap) operation
We have the following class written in Kotlin Native with the new Memory Manager (which doesn't require to freeze objects):
...
4
votes
2
answers
2k
views
Mutually exclusive execution using std::atomic?
I am currently learning more about lock free programming and wondered how I could implement mutual exclusion using std::atomics. I implemented the following code to ...
0
votes
1
answer
323
views
Flippable atomic boolean
I was trying to implement a boolean that can be atomically flipped.
The suggestion on Stack Overflow is to use an integer.
This would be my implementation.
...
3
votes
2
answers
459
views
C++11 revised `std::latch` implementation
This question follows up on this question.
After turning the while-loop into a conditional wait using std::condition_variable, I ...
1
vote
1
answer
451
views
Implementation of a latch
As an exercise to learn more about multi-threading and atomic operations work in C++, I decided to implement a latch class in C++11 loosely based off of std::latch ...
22
votes
3
answers
7k
views
C++ lock-free, MPMC Ring buffer in C++20
I have some performance critical inter-thread messaging code in C++. Multiple producers, one or more consumers.
Profiling dozens of iterations of this messaging code over several years of development, ...
6
votes
1
answer
1k
views
Implementation of std::atomic<std::shared_ptr<T>> for C++20
As you may know, C++20 has added std::atomic<std::shared_ptr<T>> specialization to the standard, but sadly, most compilers have not implemented it yet. ...
1
vote
1
answer
578
views
3
votes
2
answers
430
views
A toy example of the concurrent stack via atomic variables and CAS pattern
I've written a toy example of the concurrent stack which has only three functions push(), peek(), and ...