variables shared between a user process and its agent state, either wants-in or idle user-sem and agent-sem, local semaphores, initially 0 agent repeat await token forward token if state = wants-in signal user-sem wait agent-sem endif forever enter-cs state = wants-in wait user-sem await token exit-cs state = idle signal agent-sem forward tokenAssume that the token takes at most "cycle" seconds to circulate around the ring, even if each and every user on the ring enters the critical section and holds the token for as long as possible. Assume that "await token or timeout after time n" is an available option. Assume that "send token(m)" and "await token(m)" are allowed, where m is a message attached to the token.
Part A: Write detailed pseudocode for a replacement version of this code that will survive the loss of a token by regenerating exactly one token. Assume all processes continue to run and the only error that interests you is loss of a token on a communications link around the ring.
Part B: What UNIX service provides the equivalent of "await token(m) or timeout after time n"? (There is such a service. It is an afterthought. It was added along with the socket mechanism when network support was added to UNIX).