October 18th, 2008, 08:45 AM
User-mode semaphore possible?
In win32, I believe the following is true. EnterCriticalSection() and LeaveCriticalSection() can be used to synchronize threads without requiring expensive system calls that transition into kernel-mode when there is no contention on the lock object. They do this by using a specific test-and-set instruction on the CPU. When there is contention on the lock, blocked threads will wait on a kernel object and are not awakened until the lock is released.
I believe a semamphore is a more fundamental synchronization object and would like to know if it is possible to make one that does not require entering kernel-mode when there is no contention. That is, can it be made if you have access to TestAndSet() and any waitable kernel objects, such as events and semaphores? (I'm fairly sure Enter/LeaveCriticalSection() can be emulated from these.)
Eagerly awaiting responses...
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!