Understanding Semaphore Objects

This post talks about Semaphore Objects – a kernel-mode synchronization object that maintains a count between zero and a maximum specified value. Semaphores’re similar to mutexes in that they allow exclusive access to a resource. What’s unique about semaphores’s that they use a resource counting mechanism. This allows a certain number of threads to access the […]

Share online:

This post talks about Semaphore Objects – a kernel-mode synchronization object that maintains a count between zero and a maximum specified value. Semaphores’re similar to mutexes in that they allow exclusive access to a resource. What’s unique about semaphores’s that they use a resource counting mechanism. This allows a certain number of threads to access the resource. Let’s say that we have a system with 3 USB ports.  Since there are three ports, we want to allow three threads to concurrently access one of the available ports.  What happens is that the semaphore is created with a maximum resource count of 3.  As each thread tries to access the port, a check is made to see if the semaphore’s resource count is greater than zero.  If it is, then the thread is allowed to access the port, and the resource count is decremented by 1.[…]

Additional MSDN Resources:

Full ArticlePerformance Blog

About The Author

Deepak Gupta is a IT & Web Consultant. He is the founder and CEO of diTii.com & DIT Technologies, where he's engaged in providing Technology Consultancy, Design and Development of Desktop, Web and Mobile applications using various tools and softwares. Sign-up for the Email for daily updates. Google+ Profile.