Make C++ thread interface thread-safe #24

Open
opened 2026-01-29 22:23:37 +00:00 by claunia · 0 comments
Owner

Originally created by @dmik on GitHub (Mar 31, 2020).

There is C++ thread support added by @komh in 203e99b908. 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.

Originally created by @dmik on GitHub (Mar 31, 2020). 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bitwiseworks/gcc-os2#24