binary semaphore vs mutex
I always had a doubt about why do we use mutex instead of binary semaphores or vice a versa. Basically what is practical difference between both.
I knew theoretical answers like semaphores are used to lock shared variables between processes as well, unlike mutex.
Today I realized that I was confused because of linux’s implementation of mutex. Ideally mutex lock shouldnt be released by other process, but this is allowed in linux and hence process synchronization can be done using mutex. But theoretically mutex should be used for mutual exclusion and binary semaphores for process synchronization.
here mutex can not be used.
Also mutex can be used for shared memory between two processes. (It is by defualt not enabled and you have to pass some flag).