Is there any relation between them? What's the difference on the implementation and the performance?
There's no direct relationship.
pthread_mutex_lock() is a userspace API, implemented in the C library. On Linux, it's usually based on the kernel futex() system call.
mutex_lock() is an internal kernel API, implemented within the kernel itself and only available there. It's based around spinlocks and direct manipulation of the current task's schedulable state, usually with architecture-optimised fast paths.
It makes no sense to compare the performance because they are not interchangeable - where you can use one, you cannot use the other and vice-versa.
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