This is the mail archive of the
mailing list for the libstdc++ project.
Re: C++ constructor calling futex_wake then _spin_lock
- From: Florian Weimer <fweimer at redhat dot com>
- To: "Xavier R. Guérin" <guerinx at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 10 Jul 2012 09:30:38 +0200
- Subject: Re: C++ constructor calling futex_wake then _spin_lock
- References: <CFC73AE8-544B-44D9-9E96-664B96DF32C3@gmail.com>
On 07/10/2012 03:54 AM, "Xavier R. Guérin" wrote:
I am experimenting with RAII for locks and uses a stack object to initialize a lock. While this method is very practical, using it on the critical path of my application shows extremely strange behaviors.
It looks like somehow kernel spin locks, through futex, are involved during the construction and destruction of my RAII locker. Is this an expected behavior? It's rather counter intuitive and extremely expensive (70% CPU time with multiple threads).
Pthreads mutexes use kernel facilities for parking threads which cannot
acquire a mutex, so this behavior is expected for contended mutexes.
Avoid contention and execution will stay in user space.
I don't quite see how this is related to libstdc++, though.
Florian Weimer / Red Hat Product Security Team