Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between FUTEX_WAIT and FUTEX_WAIT_PRIVATE?

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.

like image 572
Gabriel Southern Avatar asked Apr 02 '12 21:04

Gabriel Southern


People also ask

What is Futex_wait?

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.

Is futex faster than mutex?

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.

What is futex technology?

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.


1 Answers

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

like image 83
je4d Avatar answered Oct 12 '22 04:10

je4d