No. A mutex uses a binary semaphore to implement its property of providing exclusive locks. One can implement a mutext without using a binary semaphore also....
On Jun 11, 12:43 pm, Rishi Agrawal <[email protected]> wrote: > So can we say that a mutex is a binary semaphore. > > > > > > On Thu, Jun 10, 2010 at 11:26 PM, souravsain <[email protected]> wrote: > > > Originally semaphore is a concept given by Dijkstra who says it is > > something that can have two operations P and V both atomic. In an OS > > (for example Unix) we have kernal objects called "semaphore" which > > have the same two atomic oprerations. It is used to control > > communication between 2 things (it can be 2 thread, 2 processes) as > > you have rightly mentioned. You can 'wait' for a semaphore. Someone > > else (thread/process) can broadcast a message that it has freed a > > semaphore. So emphasis is on communication. > > > Mutex is more for controlling access to some resource. I do not know > > how many threads will access an object, say a linked list. What I only > > know is that the linked list should not be manipulated simultaneously > > by 2 or more threads. So my focus is on makeing sure than the shared > > object 'linked list' is in good shape. So a Mutex is in itself an > > object which sort of guards the resoure. So the mutex says If a thread > > wants to access / change the linked list, first lock me, then do ur > > changes and unlock me. > > > Having said this, Binary semaphore is one which can change value > > between 2 states (enerally 1 and 0) and most interestingly, we > > implement a mutex object by having a binary semaphore inside the Mutex > > object. > > > class Mutex > > { > > private BinSem MySem; > > lock() > > { > > if MySem is 0 then lock or wait > > } > > unlock() > > { > > if MySem is 1 broadcast all am releasing and release. > > } > > } > > > On Jun 10, 8:56 pm, sharad kumar <[email protected]> wrote: > > > @sharad but when it is binary semaphore then only one process is > > accessing > > > the resource,rest all are blocked....which means that only that process > > who > > > locked bin. sem will unlock it .....plzzz correct me if i m wrong > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<algogeeks%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Regards, > Rishi B. > Agrawalhttp://www.linkedin.com/in/rishibagrawalhttp://code.google.com/p/fscops/- > Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
