Although little weird, toilet is actually is a very good example for this! It's intuitive to understand that you "lock" it and that one person uses it at a time.
@rishkum536
6 жыл бұрын
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.
@uzairghole3025
6 ай бұрын
There can't be a better explanation than this. I luckily happened to watch this as my first video while studying the mutex vs semaphore concepts and I can say that it took me only the duration of this video to understand the very core principle associated with this topic. Thank you.
@TheLPfunnTV
3 жыл бұрын
You might have just saved my exams grade! I understood the explanation with the metaphore so much better and it sticks. Thank you!
@omargamal2148
Жыл бұрын
don't think there's any saving if you call it a metaphore
@TheLPfunnTV
Жыл бұрын
@@omargamal2148 good one!
@totommymmy
5 жыл бұрын
Thank you so much! The toilet is such a good example for memorizing and understanding!
@pepe6666
5 жыл бұрын
it actually really is.
@nishantchauhan1548
5 жыл бұрын
Of all possible examples in the world, you chose a toilet...
@weirdopersonnal
5 жыл бұрын
hahahaha!
@justaninfiredperson
5 жыл бұрын
Nishant Chauhan 😂
@Teslacoil33
5 жыл бұрын
Lock(mutex) "Do Work" Unlock(mutex)
@mariumahmed4567
5 жыл бұрын
😂😂😂😂👏🏻👏🏻
@shovon9412
5 жыл бұрын
Of all examples the toilet will probably be most memorable
@MultiShiv19
7 жыл бұрын
Watch at 1.25x speed
@shivangikansal8025
7 жыл бұрын
me too :D
@basantachaulagain6104
7 жыл бұрын
1.5x works fine for me
@Darieee
6 жыл бұрын
I watched this at 20x guys .. I think I win
@omairbhore
6 жыл бұрын
I darieee you to watch it in 40x
@BloodHaZaRd666
6 жыл бұрын
1.25 almost english, at 2 becomes japanese
@pepe6666
5 жыл бұрын
thank you for explaining this in terms of people using the toilet. its a great example. i finally get that a semaphore is basically just an atomic integer and a waiting-mechanism really. speaking of which i need to go park a turd now. thanks very much and wish me well for my crap
@camelcase9310
3 жыл бұрын
believe or not your bathroom analogy helped me understood and finished my homework! Thank you so much.
@XEQTIONRZ
8 жыл бұрын
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.
@muhammadwasif881
7 жыл бұрын
In implementation Mutex generates busy wait and starvation so I think he is right..!
@muhammadwasif881
7 жыл бұрын
to avoid this busy wait you need to do this... [s] is the flag/switch mov ax, 0 xchg as, [s] comp ax, 0 JNZ exit sleep exit
@wildglorypsn
7 жыл бұрын
not necessarily...starvation doesn't happen often.
@subhashishsen6157
5 жыл бұрын
use mutex_try_lock() instead of mutex_lock()
@daisysunshine6606
5 жыл бұрын
thanks for the explanation i was confused
@tedz2usa
Жыл бұрын
Beautiful explanation! I always had trouble understanding semaphores intuitively until you provided the brilliant bathroom key analogy!!
@majidsaeidi7760
5 ай бұрын
most clearly example to know mutex and semaphore. Thanks
@marcosramirez2278
2 күн бұрын
So basically, mutex is a way to assign keys to processes, and semaphore keeps track of how many keys are left?
@SportsIncorporated
6 жыл бұрын
Great explanation. Made it all simple. For someone without a computer science degree, me.
@kartikpodugu
11 ай бұрын
I didn't understand clearly. Is there a specific reason we used 4 toilets and 4 keys for Semaphore example ? If we want to understand the difference, we need to have same no. of toilets for both mutex and semaphore ? Also, if 4 toilets are there, and you take the key to use toilet, then also it looks like there is ownership. What is the advantage if we have same kind of key for all 4 bathrooms ? Isn't semaphore example same as having 4 mutexes for 4 toilets ? I can't imagine what is the advantage of having same key for all 4 toilets, Please help me understand.
@shrimatkapoor2200
4 жыл бұрын
I still don't understand if the keys are identical, couldn't two threads access the same object and cause a race condition?
@Teslacoil33
5 жыл бұрын
For the semaphore, if all the keys are identical what's to stop a person opening an occupied toilet door?
@lmnefg121
4 жыл бұрын
dude, you are a genius to use the toilet and key as the metaphor here.
@saadmanahmed860
4 жыл бұрын
very very tributary illustration. great video. the idea of mutex and semaphore really come to me translucid now
@gaborm4767
3 жыл бұрын
What is the benefit of mutex over semaphore?
@burhanmuhyiddin4372
5 жыл бұрын
Thank you very much :) I also confused about the difference between mutexes and semaphores and you explained the difference very clearly.
@Shifter21000
8 жыл бұрын
Very good explanation! Crisp and clean .
@HowTomakeitdone
8 жыл бұрын
thanks
@payalsagar1808
4 жыл бұрын
honestly thankyou so much for this perfect example☺.... the concept got cleared
@TL-fe9si
6 жыл бұрын
what about P(mutex)V(mutex)? Does the semaphore now have ownership issues?
@sent4dc
7 жыл бұрын
All I could understand is "toilet."
@PK-xe6sm
6 жыл бұрын
A few times during this video I've been wondering if he did still use English
@unknownuser6143
6 жыл бұрын
sent4dc 😂😂😂😂
@nishik332
5 жыл бұрын
Did u pass in the exam
@badger6431
4 жыл бұрын
Because you are full of s-hit.
@dboothe7889
3 жыл бұрын
Great work! I now understand the difference the night before my exam. Many thanks Sir!
@ifxzrvz1706
4 жыл бұрын
thank you, your explanation is one of the best.
@enkr1
Жыл бұрын
5:43 is it comparing if it is equal to zero not less than ..?
@notoppland
Жыл бұрын
Very clear and easy to follow explanation, thank you!
@xamogxusx
4 жыл бұрын
10/10, indian enough that it was a good tutorial!
@sureshkumarkaushik6109
8 жыл бұрын
Thanks for this video and it helps us to understand the main concepts in best way. and easy to remember the conepts.
@HowTomakeitdone
8 жыл бұрын
Thanks Welcome to the channel.
@paulohanded28
7 жыл бұрын
what software did you use to do the animation?
@HowTomakeitdone
7 жыл бұрын
This is simple PowerPoint presentation
@medhm2262
5 жыл бұрын
My frend its nice exemple it will stell in my memory for ever tanks
@harshapalanki5491
4 жыл бұрын
Is binary semaphore and mutex same???
@aruprakshit7218
2 ай бұрын
Very good explanation. Loved it.
@anikettiwari6885
5 жыл бұрын
If two threads will try to access data with the help of semaphore at same time race condition can come. How can we avoid it
@SriLakshmi3395
8 жыл бұрын
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.. :-)
@HowTomakeitdone
8 жыл бұрын
Thanks for nice comment It's really great.
@baqtronic7704
5 жыл бұрын
Seems a good explanation, but I struggled very hard to understand this english... Subtitles would be very nice (not automatic...)
@daisysunshine6606
5 жыл бұрын
is english your second language? maybe thats why it was hard.
@warrenpeterson5709
Жыл бұрын
yeah i couldn't understand it either. My professor used this video as required watching but im gonna search for something else I can understand.
@Light-th1co
7 жыл бұрын
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.
@OlliS71
9 ай бұрын
Every mutex is built on top of a semaphore with the addition of an atomic for the fast path. The fast path makes uncontended locking in userspace possible with a small number of instructions.
@sagarsharma-bp5we
4 жыл бұрын
I think this difference is wrong, you have given example of counting semaphore , But we also have Binary Semaphore , Then what is difference bw binary semaphore and mutex.
@kevinfernandez2269
5 жыл бұрын
He probably went to a dollar general where you have to get a key from the register for the bathroom.
@047gauravkumartiwari5
Жыл бұрын
A clear and lucid explanation!
@peimanfarshbaf7522
5 жыл бұрын
best explanation i have ever seen
@tanaygupta632
3 жыл бұрын
I want difference between mutex and binary semaphore.
@angelakarapetyan586
3 жыл бұрын
Mutex is just a simple lock?
@rogerzheng2814
5 жыл бұрын
So isn't mutex just a special case of a semaphore?
@SoferPeOZN
3 жыл бұрын
"Let's say this person wants to use toilet facilities" =)))))))))) Nice tutorial, thanks
8 жыл бұрын
Very Good.Keep it up :)
@HowTomakeitdone
8 жыл бұрын
Welcome to channel.
@sumitkaushik1942
7 жыл бұрын
HowTo सपना
@pengxiaohan3371
2 жыл бұрын
Very clear explanation. Thanks!
@suyashvishnoi6157
7 жыл бұрын
Now i clearly understand. Thank you sir
@HowTomakeitdone
7 жыл бұрын
glad to know that :-)
@echosystemd
8 жыл бұрын
Very good. But I think you need to explain why mutex use ownership while semaphore use signaling mechanism.
@HowTomakeitdone
8 жыл бұрын
+echo Mutex allow only one process/thread to access shared data because of that it need to lock that object. Whereas semaphore multiple processes can be allowed and in order to notify them for availability of data signaling mechanism is used. Welcome to channel.
@rtm0076
4 жыл бұрын
Best explanation ever
@vivekthakkar5276
5 жыл бұрын
How can someone dislike this video?
@aizazulhaq4702
5 жыл бұрын
Yeah sure... cz there is a toilet in the video as an example.. duhhh
@michaelcrainiciuc
Жыл бұрын
Still very good explanation that made me understand, thank you
@voipims
7 жыл бұрын
This video is half....people do have confusion between mutex and binary semaphore
@teuton8363
8 жыл бұрын
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.
@HowTomakeitdone
7 жыл бұрын
thanks for your concern. I will improve audio definitely.
@High_Altitude_Observer
6 жыл бұрын
So the difference between a semaphore and a mutex is a toilet?
@gauravhiran6747
6 жыл бұрын
Toilets are "resources" and people are "threads"
@jagbandhu1987
6 жыл бұрын
What is the difference between Binary semaphore and mutex
@gauravhiran6747
6 жыл бұрын
Signalling is in term of 0 and 1 in case of binary semaphore and in mutex object is used.
@zxuiji
2 жыл бұрын
Welp, I found a way to ignore both of those, here's a snippet from what I'm currently constructing to give you an idea: ``` dint Send_AndWaitAll( THREAD *thread, OBJECT *object ) { BRANCH *branch = GrabThreadBranch( thread ); if ( !thread ) return 0; if ( thread != &main_thread ) { SIGNAL *signal = GrabThreadSignal(thread); OBJECT tmp = {0}; bool redo = false; object->que = time(NULL); signal->i = *object; while ( 1 ) { YieldOther(); /* Check if the thread sent us a signal */ if ( signal->o.que < object->que ) continue; /* Check if the signal was the one we were expecting */ if ( signal.o.sig != SIGNAL_CONT ) { tmp = signal->o; redo = true; continue; } break; } if ( redo ) { tmp.que = object->que; tmp.sig = SIGNAL_REDO; signal->i = tmp; } } Send_AndWaitAll( branch->Init, sig, object ); return Send_AndWaitAll( branch->Next, sig, object ); } ```
@zhengrui315
4 жыл бұрын
I really like this toilet, sorry i mean tutorial
@zhengrui315
3 жыл бұрын
@@blazkowicz666 seriously? you are picking a fight over this comment? I have no idea why it's offending to you
@blazkowicz666
3 жыл бұрын
@@zhengrui315 I thought that was something Racist implied before I watched the video. I have deleted the comment 🤝
@UdayKumar-zm4ft
3 жыл бұрын
🤣🤣🤣
@guptavishal981
8 жыл бұрын
is mutex used in dining philospher problem?
@HowTomakeitdone
8 жыл бұрын
Yes
@sumitkaushik1942
7 жыл бұрын
HowTo सपना
@sumitkaushik1942
7 жыл бұрын
सपन
@sumitkaushik1942
7 жыл бұрын
सपन
@bluesteel1
3 жыл бұрын
Very very nice explanation
@seba_duran
8 жыл бұрын
thanks for the video, now I understand better
@HowTomakeitdone
8 жыл бұрын
Welcome to the channel
@KNT_19
7 жыл бұрын
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?
@HowTomakeitdone
7 жыл бұрын
If you want only one resource to be accessed at one time then you need to take semaphore value accordingly.
@gauravhiran6747
6 жыл бұрын
Use java "synchronised" keyword.
@SubcribetoTin
8 жыл бұрын
Thanks! Simple and straight to the point.
@HowTomakeitdone
8 жыл бұрын
thanks welcome to the channel.
@TellaTrix
Жыл бұрын
Appreciate for your explanation!
@Penguinsxz
8 жыл бұрын
Thanks for the awesome review!
@HowTomakeitdone
8 жыл бұрын
welcome to the channel.
@killstriker64
6 жыл бұрын
thanks a lot for this explanation! you are awesome!
@HowTomakeitdone
6 жыл бұрын
You are welcome.
@anilkinikar
3 жыл бұрын
Very good explanation.
@shovon9412
5 жыл бұрын
Great video very clear
@jonathanazzopardipaul5048
4 жыл бұрын
This was a great explanation, thanks!
@bharat_india12
2 жыл бұрын
Watching this for tomorrow interview
@CoreDump451
Жыл бұрын
Wonderful explanation. Thank you! :)
@ameyzulkanthiwar9148
6 жыл бұрын
very nice expiation..Thank you..
@DEV-gz3nk
6 жыл бұрын
what is mutex datatype
@akhilkandibanda
7 жыл бұрын
awesome toilet example, i clearly understood
@blockobutter
4 жыл бұрын
My textbook had so much abstraction and bullshit beating-around the bush with fornal words that I didn't understand anything. All I needed was the toilet example, with multiple keys.
@openyourmind1694
3 жыл бұрын
Every theoric book says these things; I'd like to find a modern c++11/14 implementation. In real pratice we can't code description of the ideas but what we need are implementations
@fatemakhalfan6980
3 жыл бұрын
very useful...Thanks
@rajattandon5692
2 жыл бұрын
Great explanation
@MinhTran-sl7kc
4 жыл бұрын
Thank you Raja, I understand now.
@prithvisinh
6 жыл бұрын
Excellent presentation.
@amithstark8946
9 ай бұрын
very well explained
@conormcgarry4844
2 жыл бұрын
i found the speaker went faster and faster near the end and f ound it hard to understand
@Mohammed-fk9dj
6 жыл бұрын
4 identical keys for the toilet!!! what if somebody already in toilet and another person come and open the toilet! LOL
@petermako3174
5 жыл бұрын
maybe the locks work in a way, that if somebody inserts the key into the lock from the inside it prevents turning the other key from unlocking the door
@TT-ud5gf
3 жыл бұрын
This is the best question :)
@a2zuser1
5 жыл бұрын
Thank you very clear was useful
@pavanisivadath9813
8 жыл бұрын
good work in making the pictures
@HowTomakeitdone
8 жыл бұрын
thanks Welcome to the channel.
@farruhhabibullaev5316
5 жыл бұрын
What? Toilet example is funny one, Good explanation...
@pupunjena1862
6 жыл бұрын
these toilets must have gold basins,commodes,taps and stuff that is why they got keys
@victorzedwings
5 жыл бұрын
*Toilets must be a big problem elsewhere....*
@arthurimona5901
5 жыл бұрын
Thanks buddy for the informative video!
@AhmadKhanNaul1
4 жыл бұрын
Very very well method
@andresperez4698
8 жыл бұрын
muchisimas gracias.. me quedo bien claro...gracias a ud
@jigneshsatani
3 жыл бұрын
its only theoretical concept dear. totally confusing video :(. You need to explain it's main purpose why we have to use mutex and why we have to use semaphore
Пікірлер: 235