@DK: So u mean to say that Mutex and binary semaphores provide
completely same functionality. Right?
Say u have a resource R and u can provide access to this particular
only one at a time (lets say multiple threads are there).
Now we can use mutex. One by one the threads will lock it and will use
the resource and then unlock it for other threads.
We can use binary semaphore. One thread will signal it, value will be
0 and use the resource. Later, it will signal it to value 1 so now
other thread can do the same thing.

So here we dont have any difference between mutex and binary
semaphore. We can use either.

Now plz give me some examples where mutex is preferred over binary
semaphore and vice-versa.

Thanks
Dumanshu

On Jun 18, 1:58 am, DK <divyekap...@gmail.com> wrote:
> @Dumanshu/@Ankit: Of course mutexes can be made to work between processes
> (it's an implementation detail). But the *concept* of a mutex is Owner +
> (Lock & Key) pair. By adding the concept of Owner to a lock, we can ensure
> that only the person who locked the lock can open it. This *guarantees*
> mutual exclusion (which is unlike a semaphore). A semaphore is a signalling
> mechanism between threads/processes that simply indicates an event that has
> occured asynchronously to the process/thread's flow of control (for
> processes/threads other than the event generating process of-course). It is
> often used to indicate that cooperative progress may be possible on
> resources under contention or synchronization between states may be
> required. Any cooperating process/thread can modify the value of a semaphore
> which is not true of a mutex.
>
> Note: Mutex and Semaphore are essentially concepts. Their implementations
> can vary in different systems and have different implementation constraints
> but the theory is clear. The two are different and serve different purposes
> though they may share implementation details.
>
> --
> DK
>
> http://twitter.com/divyekapoorhttp://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to