Sequenced-Before for g++ 4.1.2?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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 {
   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.


[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google