Posts

Showing posts from July, 2020

Mutex vs Semaphore

                                   Mutex vs Semaphore     https://www.youtube.com/watch?v=DvF3AsTglUU Mutex and Semaphore both provide synchronization services but they are not the same. Details about both Mutex and Semaphore are given below − Mutex Mutex is a mutual exclusion object that synchronizes access to a resource. It is created with a unique name at the start of a program. The Mutex is a locking mechanism that makes sure only one thread can acquire the Mutex at a time and enter the critical section. This thread only releases the Mutex when it exits the critical section. This is shown with the help of the following example − wait ( mutex ); ….. Critical Section ….. signal ( mutex ); A Mutex is different than a semaphore as it is a locking mechanism while a semaphore is a signalling mechanism. A binary semaphore can be used as a Mutex but a Mutex can never be...