go mutex (syn package)

Concurrent programming has not been sorted out yet, let’s post about mutexes first (refer to Li Wenzhou’s blog) Mutex In Go language, the Mutex type provided in the sync package is used to implement mutual exclusion locks. The bottom layer of this type is a structure, and the structure is a value type. If it […]

Related usage scenarios of mutex in ATF

bakery lock Let’s take a look at the appearance of this bread in ATF. Scenario 1: Runtime service initialization BL31 is responsible for initializing runtime services. One of them is PSCI. As part of PSCI initialization, BL31 detects the system topology. It also initializes the data structures implementing the state machines used to track the […]

Java uses mutex to solve cache breakdown problem

1. Cache breakdown principle The cache breakdown problem is also called the hotspot key problem, which means that a key with high concurrent access and complex cache business suddenly fails, and countless access requests bring a huge impact to the database in an instant. 2. The principle of mutual exclusion lock The mutual exclusion lock […]

One article clearly explains the principles and usage of C language multithreading, signals, mutexes, and condition variables (including cases)

Introduction Thread (Thread): A thread is a concurrent execution flow within a program, also known as a lightweight process. Unlike processes, threads share the same memory space, so data and communication can be shared more easily. Threads can be created, destroyed, synchronized and communicated through the pthread library. Signal (Signal): Signal is an inter-process communication […]

C++11 threads, mutexes and condition variables

Article directory foreword 1. Create the first thread 2. The life cycle, waiting and separation of thread objects 3. Multiple ways to create threads 4. Mutex 4.1 Exclusive mutex std::mutex 4.2 Recursive exclusive mutex recursive_mutex 4.3 Mutex std::timed_mutex and std::recursive_timed_mutex with timeout 4.4 std::lock_guard and std::unique_lock 5. Use of call_once/once_flag 6. Condition variables Foreword Before […]

Thread synchronization mutual exclusion mutex, read-write lock, condition variable

1. Basic concepts Mutex and synchronization are the most basic logical concepts: Mutual exclusion refers to controlling two processes so that they are mutually exclusive and do not run at the same time. Synchronization refers to controlling two progresses so that they come first and then come first, and the order is controllable. 2. Mutex […]

C++ high performance: std multithreading thread, mutex, condition_variable future

mutex std::mutex std::mutex mtx;,mtx.lock();,mtx.unlock(); // https://cplusplus.com/reference/mutex/mutex/ // mutex example #include <iostream> // std::cout #include <thread> // std::thread #include <mutex> // std::mutex std::mutex mtx; // mutex for critical section void print_block (int n, char c) {<!– –> // critical section (exclusive access to std::cout signaled by locking mtx): mtx. lock(); for (int i=0; i<n; + + […]