Strictly speaking, mutex is a locking mechanism whereas semaphore is a signaling mechanism.
Mutex is the lock to a toilet and semaphore is the number of identical keys to a shared resource.
Imagine a buffer being split up into 4 parts and then the semaphore count can become 4, i.e there are now 4 instance to the same resource. Mind it , it is not the same resource. A semaphore with a value of 0 is similar to mutex but is has a difference, in mutex ,the thread within the same process can unlock the mutex whereas in semaphore an external thread can also free the semaphore by giving wakeup signal.
Mutex is the lock to a toilet and semaphore is the number of identical keys to a shared resource.
Imagine a buffer being split up into 4 parts and then the semaphore count can become 4, i.e there are now 4 instance to the same resource. Mind it , it is not the same resource. A semaphore with a value of 0 is similar to mutex but is has a difference, in mutex ,the thread within the same process can unlock the mutex whereas in semaphore an external thread can also free the semaphore by giving wakeup signal.
thank u...sir..i had doudt in this topic.its 100% cleared now.
ReplyDeleteThanks For Your Blog
ReplyDeleteChemistry Honors
General Chemistry
find here human hair wigs,costume wigs,cheap wigs,wigs,human hair toppers,human hair toppers,human hair wigs,hair toppers,human hair toppers check it out
ReplyDelete