What is difference between Semaphore and Mutex

What is difference between Semaphore and Mutex
Mutex is a object owned by thread who is executing in critical section whereas semaphore is a signaling mechanism.

RRelated Posts

Mutex Synchronization in Linux with Pthreads

Demo of using threads in Linux (pthreads) to run very simple processing in parallel. Uses a mutex (pthread_mutex) to synchronize the processing to avoid a race condition. Support videos via Patreon:


  • OMM
  • itsurguy1
    He did not explain counting semaphore and binary semaphore. Not goood
  • sudharshan penujuri
    Nice examples 😂
  • Satyaprakash Sahoo
    Actually binary semaphore is one type of mutex
  • mrtrex01
    does 1 key represent 1 core?
  • Rish Kum
    I am on my way to a Computer Science degree. I have a very good professor but you explained it way better and made it easier.
  • Tushita Patel
    what's a chat?
  • Subodh Dhakal
    These dumbass people saying your English is bad and stuff like that. Fuck 'em. The most important thing you are doing is sharing knowledge and you could have done that in your own language but you chose English. Thank you so much for that. Highly appreciated!
  • Amit Singh Solanki
    Good tutorial
  • GeishaTheSerpantClan
    Typical Indians using joke about the toilet. Because they are still having bad with hygienes toilets...
  • SpringInFialta
    Chad-1, Chad-2, and Chad-3? Is this a MUTEX video or a MGTOW video?
  • T L
    what about P(mutex)<code block>V(mutex)? Does the semaphore now have ownership issues?
  • Nadeem Akram wattoo
  • Jagbandhu Sahu
    What is the difference between Binary semaphore and mutex
  • kill striker64
    thanks a lot for this explanation! you are awesome!
  • manthan shah
  • Mohammed Arshad
    4 identical keys for the toilet!!! what if somebody already in toilet and another person come and open the toilet! LOL
  • Ashish Chauhan
    Thanks for video
  • High Altitude Observer
    So the difference between a semaphore and a mutex is a toilet?
  • ps z
    Excellent presentation.
  • Pupun Jena
    these toilets must have gold basins,commodes,taps and stuff that is why they got keys
  • DEV
    what is mutex datatype
    Great explanation. Made it all simple. For someone without a computer science degree, me.
  • Amey Zulkanthiwar
    very nice expiation..Thank you..
  • doskodo
    how can I close a mutex in a process? Tell me please how can I do it in a batch file or per cmd.exe.
  • Suyash Vishnoi
    Now i clearly understand. Thank you sir
  • Paulo Haddad
    what software did you use to do the animation?
  • Adharsh Mohan
    good explanation. Thanks..
  • Wilson Farias
    Thank you for the video!
  • Amit Singh
    Wrong concept explained for semaphore
  • Yu Zhao
    omfg spiderman desktop
  • Zheng SUn
    love that pictures!!!!! thank you
  • sent4dc
    All I could understand is "toilet."
    In case of semaphore, if the two threads accessing a shared resource, there will be race condition. Can tell, in this case, how synchronization is achieved?
  • koti571 bulasara
    good explanation
  • Akhil Kandibanda
    awesome toilet example, i clearly understood
  • Thành Lợi Nguyễn
    Thank you thank you so much!
  • Bossin Shid 3x
    is this english ? i doubt it
  • Sharief Muzammil
    Easily understood.
  • Lavanya Bellamkonda
    nice video.thank you
  • MultiShiv19
    Watch at 1.25x speed
  • Reiner03
    Very good!
  • voipims
    This video is half....people do have confusion between mutex and binary semaphore
  • dhairya gajjar
    What is the difference between binary semaphore and mutex?
  • john/flag
    Thanks for the video, but please buy a good microphone. If video quality is bad thats one thing but audio quality should always be good, otherwise people tune out quickly.
  • Sri Lakshmi
    Thanks a billion times.....U have such an awseome talent of explaining the most difficult stuff in the easiest possible way.....
    Before watching ur videos ,I struggled with Computer science.... Ur channel & ur way of simple easy teaching increased my passion for Computer Science...I wish u all success & healthy happy life.. God bless u.. :-)
  • Anarghya Jantali
    Very good explanation! Crisp and clean .
  • Vishal Gupta
    is mutex used in dining philospher problem?
  • Coque JC
    I love u mate
  • Ovi Hussain
    The only issue with your explanation is that when a mutex is locked, another thread trying to access the mutex doesn't get returned an error as you say. It just waits until the mutex is unlocked. I think you get it, just worded it improperly. Otherwise good video.