Entries by Rainer Grimm

My ALS Journey (21/n): ALS Fundraiser by Jen and Jason

Today, I want to present you something special. >> My ALS Journey so far << ALS Fundraiser by Jen and Jason https://x.com/lefticus/status/1895996735610032400 I cannot express how happy I am to have such friends! Jen and Jason, have a good journey. From one Week to two Weeks You may have already noticed. I will change my […]

A Lock-Free Stack: A Hazard Pointer Implementation

Hazard Pointers solve all issues of the previous implementation: A Lock-Free Stack: A Simple Garbage Collector. From one Week to two Weeks You may have already noticed. I will change my blog publishing frequency from one to two weeks in the future. Writing a post using your voice is exceptionally exhausting and time-consuming. Hazard Pointers […]

A Lock-Free Stack: A Simple Garbage Collector

My next lock-free stack includes a simple garbage collector. I discussed the concurrent execution of more than one topAndPush call is a Race Condition. I can safely delete a node if not more than one topAndPush call is executing concurrently. This observation is crucial for solving this memory leak issue: I store removed nodes on […]

A Lock-Free Stack: Atomic Smart Pointer

The easiest way to solve this memory leak issue from the last post is to use a std::shared_ptr. Atomic Smart Pointer There are two ways to apply atomic operations on a std::shared_ptr: In C++11, you can use the free atomic functions on std::shared_ptr. With C++20, you can use atomic smart pointers. C++11 Using atomic operations […]

A Lock-Free Stack: A Complete Implementation

My last lock-free stack implementation was incomplete. It only supported push operations. Let’s change this. The following paragraph about sequential consistency is optional. You can easily ignore it. Sequential Consistency In my examples, I use the default memory ordering: sequential consistency. The reason is simple. Sequential consistency provides the strongest guarantees of all memory ordering […]

My ALS Journey (20/n): Aids

Today, I would like to introduce all the important aids that allow me and Beatrix to get through the day >> My ALS Journey so far << Aids Caregivers Of course, caregivers are not aids, but they still belong on this list. I can now have 24/7 care. This care is an incredible help for […]

A Lock-Free Stack: A Simplified Implementation

Today, I continue my mini story about lock-free data structures. General Considerations From the outside, the caller’s responsibility (application) is to protect the data. From inside, the data structure is responsible for protecting itself. A data structure that protects itself so a data race cannot appear is called thread-safe. First, what general considerations must you […]

Deferred Reclamation in C++26: Read-Copy Update and Hazard Pointers

Before I dive into lock-free programming, there’s a little bit of theory necessary. A common problem in concurrency is the so-called ABA problem. That means you read a variable twice, which returns the same value each time, A. Therefore, you conclude that nothing changed in between. But you forgot the B. Let me first use […]

std::format Extension

Displaying the address of an arbitrary pointer in C++ 20 fails but succeeds with C++26. C++20 Only void, const void, and std::nullptr_t pointer types are valid. If you want to display the address of an arbitrary pointer, you must cast it to (const) void*. // formatPointer20.cpp #include <format> #include <iostream> #include <string> int main() { […]