Bloomberg LP Interview Question
Financial Software DevelopersCountry: United States
Interview Type: Phone Interview
In the old days, Mutex Locks need hardware support and essentially there are many schemes to ensure Lock atomicity some eg. are LL_SC, Test&set, Ticket or Token based, Array Locks with back off schemes ...c++11 is supposed to have added mutex lock featurees for a fully parallel/multi threaded execution of a single program code.
from stackoverflow.com/questions/5095781/how-pthread-mutex-lock-is-implemented
In Linux, for example, a system called Futex (Short for Fast Userspace Mutex) is used.
In this system an atomic increment and test operation is performed on the mutex variable in user space.
If the result of the operation indicates that there was no contention on the lock, the call to pthread_mutex_lock returns without ever context switching into the kernel, so the operation of taking a mutex can be very fast.
Only if contention was detected does a system call (called futex) and context switch into the kernel occurs that puts the calling process to sleep until the mutex is released.
i think the appropriate answer for this question would be how they are implemented :that is the program they use to implement that is like test and set program: these programs are implemented by the hardware developers such as intel which uses xchnge
- sai s February 05, 2013