Implemented semaphores for periodic tasks