Barriers and Atomic Smart Pointers in C++20

In my last post, I introduced latches in C++20. A latch enables its threads to wait until a counter becomes zero. Additionally, to a latch, its big sibling barrier can be used more than once. Today, I write about barriers and present atomic smart pointers.

Read more
Views: 16821

Performance Comparison of Condition Variables and Atomics in C++20

After the introduction to std::atomic_flag in my last post Synchronization with Atomics in C++20, I want to dive deeper. Today, I create a ping-pong game using condition variables, std::atomic_flag, and std::atomic<bool>. Let's play.

Read more
Views: 37471

Synchronization with Atomics in C++20

Sender/receiver workflows are quite common for threads. In such a workflow, the receiver is waiting for the sender's notification before it continues to work. There are various ways to implement these workflows. With C++11, you can use condition variables or promise/future pairs; with C++20, you can use atomics.

Read more
Views: 23883

Atomic References with C++20

Atomics receives a few important extensions in C++20. Today, I start with the new data type std::atomic_ref.

Read more
Tags: atomics
Views: 18110

C++20: Concurrency

This post concludes my overview of C++20. Today's post is about the concurrency features in the next C++ standard.

Read more
Views: 41442

ABA - A is not the same as A

A common problem in concurrency is the so-called ABA problem. That means you read a value twice and each time it returns the same value A. Therefore you conclude that nothing changed in between. But you forgot the B.

Read more
Tags: atomics
Views: 27883

Blocking and Non-Blocking Algorithms

Blocking, non-blocking, lock-free and wait-free. Each of these terms describes a key characteristic of an algorithm when executed in a concurrent environment. So, reasoning about the runtime behaviour of your program often means putting your algorithm in the right bucket. Therefore, this post is about buckets.

Read more
Views: 64466

My Conclusion: Summation of a Vector in three Variants

After I've calculated in three different ways the sum of a std::vector I want to draw my conclusions.

Read more
Views: 34789

Multithreaded: Summation with Minimal Synchronization

Until now, I've used two strategies for the summation of a std::vector. First, I did the whole math in one thread (Single Threaded: Summation of a vector); second multiple threads shared the same variable for the result (Multithreaded: Summation of a vector). In particular, the second strategy was extremely naive. In this post, I will apply my knowledge of both posts. My goal is that the thread will perform their summation as independently from each other as possible and therefore reduce the synchronization overhead. 

Read more
Views: 21686

Single Threaded: Summation of a Vector

What is the fastest way to add the elements of a std::vector?. A question which I will pursue in the next posts. I use the single-threaded addition as the reference number. In further posts, I discuss atomics, locks, and thread-local data.

Read more
Tags: atomics, lock
Views: 26389


Stay Informed about my Mentoring

English Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Interactive Course: The All-in-One Guide to C++20

Subscribe to the newsletter (+ pdf bundle)

Blog archive

Source Code


Today 2081

Yesterday 5448

Week 28994

Month 158499

All 10703615

Currently are 136 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments