TODO: implement the semaphore to help processes access the shared memory