working implementation of semaphore list