Reader writer problem in c, with threads using semaphores to solve. ( Mock database functions)