Bloomberg LP Interview Question
A mutex is a lockable object that is designed to signal when critical sections of code need exclusive access. Of course, it prevents other threads with the same protection from executing concurrently and access the same memory locations. If miused on readable/sharable sections, it causes thread holdups and response delays for other threads.
If you need synchronization between threads mutexs are costly, use critical sections instead.
mutex have property that only owner can release it. So in a threading environment if some thread sets mutex on some shared address and it goes for long time I/O sleep or not scheduled for a long time (may be cause of lower priority) then other threads needy of that locked address will have to wait (may be infinitely causing deadlock). So generally in some operating systems ,afaik threads reset the mutex lock if any before going to sleep. Any improvements?
- mrn July 17, 2011