acquire-release semantic

Thread-Safe Initialization of a Singleton

There are a lot of issues with the singleton pattern. I'm totally aware of that. But the singleton pattern is an ideal use case for a variable, which has only to be initialized in a thread safe way. From that point on you can use it without synchronization. So in this post I discuss different ways to initialize a singleton in a multithreading environment. You get the performance numbers and can reason about your uses cases for the thread safe initialization of a variable.

Read more
Comments 5Views: 4768

Ongoing Optimization: A Data Race with CppMem

But we can do better and further improve the acquire-release semantic of the last post. Why should x be an atomic? There is no reason. That was my first, but incorrect assumption. See why?

Read more
Comments 1Views: 1108

Ongoing Optimization: Acquire-Release Semantic with CppMem

With the acquire-releae semantic, we break the sequential consistency. In the acquire-release semantic the synchronization takes place between atomic operations on the same atomic and not between threads.

Read more
Add CommentViews: 825

Acquire-Release Fences

Acquire and release fences guarantees similar synchronisation and ordering constraints as atomics with acquire-release semantic. Similar, because the differences are in the details.

Read more
Comments 10Views: 2285

Fences are Memory Barriers

The key idea of a std::atomic_thread_fence is, to establish synchronisation and ordering constraints between threads without an atomic operation.

Read more
Comments 8Views: 3644

Acquire-Release Semantic - The typical Misunderstanding

A release operation synchronizes-with an acquire operation on the same atomic variable. So we can easily synchronise threads, if ... . Today's post is about the if.

Read more
Add CommentViews: 2634

memory_order_consume

std::memory_order_consume is the most legendary of the six memory models. That's for two reasons. At one hand, std::memory_order_consume is extremely hard to get. At the other hand - that may change in the future - no compiler supports it.

Read more
Comments 2Views: 4111

Support my blog by buying my E-book

Latest comments

Modernes C++

Subscribe to the newsletter

Including two chapters of my e-book
Introduction and Multithreading

Blog archive

Source Code

Visitors

Today 2121

All 228135

Currently are 158 guests and no members online