They asked me this question — what’s the difference between mutex and semaphore during an interview
<p>It seems hard for my friend who is a self-taught developer.</p>
<h1>Beginning</h1>
<p>“Last week they asked me what is multi-threading and if have I ever done anything with that, I answered the question”. my friend said.</p>
<p>“Okay sounds good, hope you will pass it”. I told him.</p>
<p>“But then he asked me how to make sure resources safely be accessed in multi-threading situations”. he said.</p>
<p>“You should know lock right?” I told him.</p>
<p>“Yes I answered him lock but then he asked what is semaphore and what is the difference I have no idea what is semaphore so I told the interviewer I don’t know could you tell me what is that ?”. he said.</p>
<p>“then did he tell you the answer?” I asked.</p>
<p>“Yes, he said semaphore is a signal mechanism which is used for thread synchronization; and the purpose of a mutex is to protect resource access from other threads while only allowing one thread to use it,” he said.</p>
<p>“So you got it?” I asked.</p>
<p>“No…can you explain to me how it works under the hood without too many CS terms?” he asked.</p>
<p><a href="https://iorilan.medium.com/they-asked-me-this-question-whats-the-difference-between-mutex-and-semaphore-during-an-interview-d862bb053f86">Read More</a></p>