LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   mutex vs semaphore (https://www.linuxquestions.org/questions/programming-9/mutex-vs-semaphore-919435/)

vishnu anand 12-19-2011 03:18 AM

mutex vs semaphore
 
what is difference between mutex and semaphore?? in which case do we use mutex and in which case we use semaphore??

markcole 12-19-2011 03:41 PM

Quote:

Originally Posted by vishnu anand (Post 4553478)
what is difference between mutex and semaphore?? in which case do we use mutex and in which case we use semaphore??

They are basically the same thing. They are both used to control access to a resource. The main difference is that a mutex is set or not set, where a semaphore is typically assigned an interger n that allows n number of concurrent accesses before access is denied.

There are a bunch of decent guides on mutexes/semaphores. Here is one -->http://www.yolinux.com/TUTORIALS/Lin...ixThreads.html


All times are GMT -5. The time now is 05:12 AM.