Implement a mutual exclusion service among n processes using Raymond’s tree based distributed mutual exclusion algorithm. The service provide two function calls to the application: csEnter() and csLeave(). The first function call csEnter() allows an application to request permission to start executing its critical section. The function call is blocking and returns only when the invoking application can execute its critical section. The second function call csLeave() allows an application to inform the service that it has finished executing its critical section. Also, implement the greedy variant of the algorithm in which a process uses the token to satisfy its own request, if applicable, before forwarding the token to the top most requesting process in its queue.
Implementation Details: each process or node consists of two separate modules. The top module implements the application (requests and executes critical sections). The bottom module implements the mutual exclusion service. The two modules interact using csEnter() and csExit() functions.
Application: The application is responsible for generating critical section requests and then executing critical sections on receiving permission from the mutual exclusion service. Application uses following two parameters: inter-request delay and cs-execution time. The first parameter denotes the time elapsed between when a node’s current request is satisfied and when it generates the next request. The second parameter denotes the time a node spends in its critical section. Assume that both inter-request delay and cs-execution time are random variables with exponential probability distribution.