What type of lock generally does a Pthreads mutex use?
This question is also asked on stackoverflow: http://stackoverflow.com/questions/5095781/how-pthread-mutex-lock-is-implemented
The answer says that it uses a system called futex which uses atomic increment and test operations on user space to implement the lock.
Here is a software implementation of pthread mutex lock: ftp://sourceware.org/pub/pthreads-win32/sources/pthreads-w32-2-9-1-release/pthread_mutex_lock.c I believe this an implementation for windows 32 bit architecture. When though I'm not really sure how 32 bit versus 64 bit differs on this since the compiler should be able to deal with that.
Also, after reading @zhanpenf's comment, I was curious about what futex's are and here is a great explanation I found on the internet: http://bartoszmilewski.com/2008/09/01/thin-lock-vs-futex/
What type of lock generally does a Pthreads mutex use?
This question is also asked on stackoverflow: http://stackoverflow.com/questions/5095781/how-pthread-mutex-lock-is-implemented
The answer says that it uses a system called futex which uses atomic increment and test operations on user space to implement the lock.
Here is a software implementation of pthread mutex lock: ftp://sourceware.org/pub/pthreads-win32/sources/pthreads-w32-2-9-1-release/pthread_mutex_lock.c I believe this an implementation for windows 32 bit architecture. When though I'm not really sure how 32 bit versus 64 bit differs on this since the compiler should be able to deal with that.
Also, after reading @zhanpenf's comment, I was curious about what futex's are and here is a great explanation I found on the internet: http://bartoszmilewski.com/2008/09/01/thin-lock-vs-futex/