Using C++ Atomic Variables

Using C++ Atomic Variables

Overview: Atomic variables are used in multithreaded programming to achieve synchronization without using mutexes, relying on hardware-supported atomic operations, which are generally more efficient than locks. Common Methods load(): Retrieves the value from the atomic variable. store(val): Stores the value val into the atomic variable. oldVal exchange(val): Stores the value val into the atomic variable … Read more

Jolt Physics 5.2.0: A Beginner’s Guide to a Multithreaded Rigid Body Physics Engine

Jolt Physics 5.2.0: A Beginner's Guide to a Multithreaded Rigid Body Physics Engine

Jolt Physics 5.2.0: A Beginner’s Guide to a Multithreaded Rigid Body Physics Engine Jolt Physics is a multithreaded rigid body physics and collision detection library designed specifically for games and VR applications, written in C++. It has emerged in modern game development due to its excellent performance and stability. This article will introduce the core … 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

A Detailed Explanation of Python GIL

A Detailed Explanation of Python GIL

What is GIL GIL (Global Interpreter Lock) is a global lock in the CPython interpreter: At any given time, only one thread can execute Python bytecode; Even if you have many threads in the same process, only one thread can actually run Python code (the others are waiting for the lock). It is important to … Read more

C++ Polling with Sleep vs. Condition Variables

C++ Polling with Sleep vs. Condition Variables

In multithreaded programming, if we let a waiting thread continuously check whether a condition is met in a loop, and if it is, continue executing the corresponding processing operation, and if not, sleep for a while, can this achieve the same effect as using condition variables? The method of polling with sleep can indeed implement … 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

Concurrent Programming in Python β€” A Deep Dive into Python Multithreading

Introduction What is a Thread 1) A thread is the smallest unit of scheduling in an operating system. 2) A thread is the actual executor of a process, consisting of a set of instructions (the owner of process resources). 3) Multiple threads within the same process share the same memory space, allowing for direct data … Read more

DJI Embedded C++ Qt Interview Insights

Today, I bring you a set of interview insights for embedded Qt development at DJI. These questions assess both fundamentals and practical applications. Whether or not you are interviewing at DJI, these knowledge points are worth mastering if you are engaged in Qt development. 1. Why did Qt design the object tree mechanism? What problems … Read more

C++ Multithreading Magic Guide: Build Your Own Thread Factory

Stop hiring temporary workers on the street; build your own factory. A thread pool is essentially a factory. It employs a fixed number of workers (threads) and continuously receives tasks (work) that these workers will complete in turn. This is the core idea of a thread pool: Instead of hiring a worker for each task … Read more

CS110L Learning Notes (Part 4): Concurrency Programming in Rust

Introduction In the previous summary of the CS110L course, we have seen how Rust builds a solid memory safety fortress in a single-threaded environment through its Ownership and Borrowing system. However, such scenarios are rare in modern systems programming. To fully utilize the performance of multi-core processors and handle I/O-intensive tasks such as network requests, … Read more