This is the mail archive of the gcc-help@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]

Sequenced-Before for g++ 4.1.2?


Hi,

I am still on 4.1.2 (which defaults to use C98), and I wonder whether g++ 4.1.2 guarantees that everything happens before (e.g. write to a variable) will be reflected in another thread if:
1. there is no lock (e.g. pthread_mutex/spinlock) involving
2. the "another thread" is created (e.g. calling pthread_create) after the "write"

An concrete example:
class B {};

class A {
public:
?? std::map<long, B*> m_myMap;
?? A::A() {
?????? m_myMap[0] = new B();
?????? pthread_t threadID;
?????? pthread_create(&threadID, NULL, start, NULL);
?? }
?? static void* start(void*) {
?????? // use m_myMap[0] here, will this new thread sees everything happens before it gets created (e.g. m_myMap[0] contains the valid value)?
?? }
}

Thanks in advance.


Cheers,
Hei


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