* Jonathan Wakely via Libstdc:

> We can't use __libc_single_threaded to replace __gthread_active_p
> everywhere. If we replaced the uses of __gthread_active_p in std::mutex
> then we would elide the pthread_mutex_lock in the code below, but not
> the pthread_mutex_unlock:
>
>   std::mutex m;
>   m.lock();            // pthread_mutex_lock
>   std::thread t([]{}); // __libc_single_threaded = false
>   t.join();
>   m.unlock();          // pthread_mutex_unlock

Thanks for implementing this.

Eliding the mutex lock is a bit iffy because the mutex may reside in a
shared mapping.  For doing the same optimization in glibc, we will
have to check if the mutex is process-private or not.

Reply via email to