This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimization of conditional access to globals: thread-unsafe?


Andrew Haley wrote:

Hmmm.  This is an interesting idea, but it sounds to me as though it's
somewhat at variance with what is proposed by the C++ threads working
group.  In any case, gcc will certainly implement whatever the
standards committees come up with, but that is probably two years
away.

One problem at the language standards level is that you can't easily talk about loads and stores, since you are defining an as-if semantic model, and if you make a statement about loads and stores, any other sequence which behaves as if that sequence were obeyed is allowed. In the absence of a notion of threads at the semantic level it's difficult to say what you mean in a formal way. In the Ada standard, we get around this problem by having sections called "implementation advice", which in practice are treated as requirements, but we can use language that is not formally sound, even though everyone knows what we mean. Of course in Ada there is a clear notion of threads semantic, and a clear definition of what the meaning of code is in the presence of threads, so the specific situation discussed here is easy to deal with (though Ada takes the view that unsychronized shared access to non-atomic or non-volatile data from separate threads has undefined effects).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]