I have been tracing a process with strace and have seen entries such as:
futex(0x7ffff79b3e00, FUTEX_WAKE_PRIVATE, 1) = 1 futex(0x7ffff79b3e00, FUTEX_WAIT_PRIVATE, 2, NULL) = 0
However, when I looked at the man page for futex I have only seen entries such as FUTEX_WAIT
and FUTEX_WAKE
. So my question is what does _PRIVATE
that is appended to the end of these names in my strace output mean? For instance is there any difference between something like FUTEX_WAKE
that is documented in the futex man page and FUTEX_WAKE_PRIVATE
that I see in the strace output or can I assume that they are the same when I am trying to understand what is happening with the program I am debugging.
Simply stated, a futex is a kernel construct that helps userspace code synchronize on shared events. Some userspace processes (or threads) can wait on an event (FUTEX_WAIT), while another userspace process can signal the event (FUTEX_WAKE) to notify waiters.
So it's a statistical fact that in most operating systems that are POSIX compliant the pthread mutex is implemented in kernel space and is slower than a futex.
In computing, a futex (short for "fast userspace mutex") is a kernel system call that programmers can use to implement basic locking, or as a building block for higher-level locking abstractions such as semaphores and POSIX mutexes or condition variables.
This is an optimization done by linux/glibc to make futexes faster when they're not shared between processes. Glibc will use the _PRIVATE
versions of each of the futex calls unless the PTHREAD_PROCESS_SHARED
attribute is set on your mutex
It's explained in more detail here: http://lwn.net/Articles/229668/
For the purposes of your debugging, you can just ignore the _PRIVATE
suffixes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With