Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C11/C++11 Memory Model

I have two questions:

  1. I would like to know if the standards for C++11 and C11 will share the same memory model specs. I read that this is so, that in fact C11 is "inheriting" the C++11 memory model (for whatever historical reasons the latter happened either first or at the same time/with the same people, though I think Boehm, who's a C++ guy primarily, had a lot to say.) , but I'd like to make sure asking someone more knowledgeable.

  2. My next question is: will GCC ever implement this memory model at all? I haven't seen the roadmap for this, and was wondering if someone had a "scoop".

like image 610
Dervin Thunk Avatar asked Oct 09 '12 12:10

Dervin Thunk


People also ask

What is memory model in C ++ 11?

C++11 Memory Model. A memory model, a.k.a memory consistency model, is a specification of the allowed behavior of multithreaded programs executing with shared memory [1].

Does C have a memory model?

C's memory model provides something like a unique location for (almost) all objects through the & operator, and that location can be accessed and modified from different parts of the program through pointers.

What is the memory model for threads?

The memory model stipulates that changes to the values of shared variables only need to be made visible to other threads when such a synchronization barrier is reached. Moreover, the entire notion of a race condition is defined over the order of operations with respect to these memory barriers.

What is a memory model CPU?

A memory model is a way of organizing and defining how memory behaves. It provides a structure and a set of rules for you to follow when you configure how addresses, or regions of addresses, are accessed and used in your system.


1 Answers

  1. The memory model was developed for C++11, and adopted by C11. Lawrence Crowl did a lot of work to ensure that the interface for atomic operations was as close as possible. There were quite a few people involved, but you are right that Hans Boehm was one of them.

  2. GCC currently (4.7) implements a reasonable approximation of the memory model. Certainly close enough that most programs won't be able tell the difference. I'm fairly sure that full conformance is on their plan, but don't know the timetable, as I'm not involved.

like image 150
Anthony Williams Avatar answered Oct 14 '22 10:10

Anthony Williams