chapter 5 finite state machine example: mutex