bitwiseworks / gcc-os2

Port of GCC compiler to OS/2
GNU General Public License v2.0
16 stars 2 forks source link

Make C++ thread interface thread-safe #21

Open dmik opened 4 years ago

dmik commented 4 years ago

There is C++ thread support added by @komh in 203e99b9081c6951f5ac88bb6b950ac9ec779e21. However, __gthread_create and other functions dealing with shared thread data (like the thread list) are not thread-safe. This means that if two threads call __gthread_create (i.e. instantiate an std::thread object) at the same time, data corruption is likely to occur.

We should make this interface thread-safe. One way to do so is to use the Posix code, i.e. switch to using our PTHREAD library (whose pthread_create and other APIs are already thread-safe). This has also a benefit of bringing pthread key destructor support to all C++ threads (see https://github.com/bitwiseworks/pthread-os2/issues/1).

See also https://github.com/bitwiseworks/pthread-os2/issues/2#issuecomment-603811814.