What are the similarities between the Java memory model and the C++11 memory model?

The Java memory model was an important influence on the C++11 memory model, and was where we pulled the terms happens-before and synchronizes-with from. However, the C++11 memory model offers much more fine-grained control over memory ordering than the Java memory model. Java volatile variables are equivalent to C++11 std::atomic<> variables, if you use std::memory_order_acquire … Read more

How do memory_order_seq_cst and memory_order_acq_rel differ?

http://en.cppreference.com/w/cpp/atomic/memory_order has a good example at the bottom that only works with memory_order_seq_cst. Essentially memory_order_acq_rel provides read and write orderings relative to the atomic variable, while memory_order_seq_cst provides read and write ordering globally. That is, the sequentially consistent operations are visible in the same order across all threads. The example boils down to this: bool … Read more

How do “acquire” and “consume” memory orders differ, and when is “consume” preferable?

Data dependency ordering was introduced by N2492 with the following rationale: There are two significant use cases where the current working draft (N2461) does not support scalability near that possible on some existing hardware. read access to rarely written concurrent data structures Rarely written concurrent data structures are quite common, both in operating-system kernels and … Read more

What does the [[carries_dependency]] attribute mean?

[[carries_dependency]] is used to allow dependencies to be carried across function calls. This potentially allows the compiler to generate better code when used with std::memory_order_consume for transferring values between threads on platforms with weakly-ordered architectures such as IBM’s POWER architecture. In particular, if a value read with memory_order_consume is passed in to a function, then … Read more

c++, std::atomic, what is std::memory_order and how to use them?

The std::memory_order values allow you to specify fine-grained constraints on the memory ordering provided by your atomic operations. If you are modifying and accessing atomic variables from multiple threads, then passing the std::memory_order values to your operations allow you to relax the constraints on the compiler and processor about the order in which the operations … Read more

C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?

First, you have to learn to think like a Language Lawyer. The C++ specification does not make reference to any particular compiler, operating system, or CPU. It makes reference to an abstract machine that is a generalization of actual systems. In the Language Lawyer world, the job of the programmer is to write code for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)