control access to multiple resource using semaphore