How to determine active semaphores?