I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I sti
A note on futexes - they are more descriptively called fast userspace mutexes. With a futex, the kernel is involved only when arbitration is required, which is what provides the speed up and savings.
Implementing a futex can be extremely tricky (PDF), debugging them can lead to madness. Unless you really, really, really need the speed, its usually best to use the pthread mutex implementation.
Synchronization is never exactly easy
, but trying to implement your own in userspace makes it inordinately difficult.