Lecture Notes | An Introduction to Wait-Free Algorithms in C++ – CppCon 2024

Lecture Notes | An Introduction to Wait-Free Algorithms in C++ - CppCon 2024

Welcome to Ethan’s Air Garden. This is dedicated to creating a computer technology column that can be read during commutes, meals, or before bed, which is both accessible and in-depth. The theme of the lecture is “Introduction to Wait-Free Algorithms in C++ Programming,” presented by Daniel Anderson from CMU. This article records and summarizes the … Read more

C++ Mutex Optimization

C++ Mutex Optimization

Basics of Locks Locks are the core synchronization primitives in C++ concurrent programming, used to protect access to shared resources, ranging from simple variables to complex code segments. The C++11 standard library provides two core types of locks: mutex: an exclusive mutex, allowing only one thread to hold it at a time. shared_mutex: a shared-exclusive … Read more

Rust and GPU: The Future of GPU Programming

Rust and GPU: The Future of GPU Programming

Rust and GPU: The Future of GPU Programming Rust is ushering in a new era of GPU programming. It combines the language’s powerful safety and concurrency features, providing a dual guarantee of performance and reliability. Using Rust for GPU development allows you to write both CPU and GPU code simultaneously, leveraging Rust’s existing ecosystem for … Read more

In-Depth Understanding of Python Coroutine Programming

In-Depth Understanding of Python Coroutine Programming

Basics of Coroutines A coroutine is a special software construct that allows a program to pause and resume execution without losing the current execution context. Unlike threads and processes, coroutines run within a single thread and achieve concurrency through a scheduling mechanism, reducing the overhead of context switching and improving program execution efficiency. Coroutines are … Read more

How Does C++ Read-Write Lock (shared_mutex) Work?

How Does C++ Read-Write Lock (shared_mutex) Work?

Sometimes, we encounter a situation where: “many reads, very few writes.” For example, configuration, status information, coordinate parameters, etc. If all threads use <span>std::mutex</span>, then read operations will queue up, wasting performance, which is unfortunate πŸ˜… To solve this problem, C++17 introduced a smarter lock πŸ”’: “std::shared_mutex”. Why is it called a Read-Write Lock? You … Read more

The Commitment to Performance and the Transformation of Modernization: Interpreting the Revival of C++ from 2006 to 2020

The Commitment to Performance and the Transformation of Modernization: Interpreting the Revival of C++ from 2006 to 2020

Click the blue text Follow the blogger 1. Background Since the early 21st century, there has been talk of the impending end of the C++ language. Especially with the explosion of the internet economy and enterprise applications, new programming languages such as Java, C#, Python, Go, and Rust have quickly captured the market with their … Read more

Packaging MQTT into HTTP Requests in IoT

Packaging MQTT into HTTP Requests in IoT

In web development, we are accustomed to HTTP requests, while MQTT is relatively unfamiliar.Although it is possible to use MQTT on the web, it can be quite cumbersome.We first define the topic /request as the MQTT request and /response as the MQTT response, and then combine them into a single HTTP request.1. Building an MQTT … Read more

Advantages and Disadvantages of Lock-based and Lock-free Concurrency in Rust: Application Scenarios

Advantages and Disadvantages of Lock-based and Lock-free Concurrency in Rust: Application Scenarios

In Rust concurrent programming, lock-based and lock-free are two core strategies. Their advantages, disadvantages, and applicable scenarios can be summarized as follows: Feature Dimension Lock-based Concurrency Lock-free Concurrency Implementation Complexity Relatively simple and intuitive, easy to get started Complex implementation, requires deep understanding of memory models and atomic operations Performance Characteristics Performance significantly decreases under … Read more

C++ std::thread: A Cross-Platform Thread Management Tool for Concurrency

C++ std::thread: A Cross-Platform Thread Management Tool for Concurrency

In today’s world of widespread multi-core CPUs, multi-threaded concurrent programming has become an essential skill for developers. Previously, when I developed on the Linux platform using C, I typically relied on the system’s built-in pthread library. However, the biggest issue was its lack of cross-platform compatibility, as it could not be used on Windows. With … Read more

Practical C++ Atomic Operations: Techniques for Implementing Lock-Free Data Structures

In high-concurrency scenarios, have you encountered the dilemma of using mutexes to protect shared data, only to face performance bottlenecks due to frequent thread blocking? For instance, in high-frequency trading systems for order processing or server request queues, the overhead of context switching caused by lock contention often becomes the “last straw” that breaks performance. … Read more