modify mailbox to use four semaphore