## 3 Proposed Algorithm for the Generalized Local \(I_{i}\)-Mutual Inclusion  
In this section, we propose an algorithm \(l_{i}\)-LMUTIN for the case that \(k_{i}=|N_{i}|+1\). First, we explain how the safety is guaranteed. Initially, the configuration is safe, that is each process \(P_{i}\) satisfies \(l_{i}\leq|\mathcal{CS}_{i}(C_{0})|\leq|N_{i}|+1\). When \(P_{i}\) wishes to be in the \(\mathsf{OutCS}\) state, \(P_{i}\) requests permission by sending a \(\langle\mathsf{Request},ts_{i},P_{i}\rangle\) message for each process in \(N_{i}\cup\{P_{i}\}\). When \(P_{i}\) obtains a permission by receiving a \(\langle\mathsf{Grant}\rangle\) message from each process in \(N_{i}\cup\{P_{i}\}\), \(P_{i}\) changes to the \(\mathsf{OutCS}\) state. Each process \(P_{j}\) grants permissions to \(|N_{j}|-l_{j}+1\) processes at each time. Hence, at least \(l_{j}\) processes in \(N_{j}\cup\{P_{j}\}\) cannot be in the \(\mathsf{OutCS}\) state at the same time. When \(P_{i}\) wishes to be in the \(\mathsf{InCS}\) state, \(P_{i}\) changes to the \(\mathsf{InCS}\) state and sends a message \(\langle\mathsf{Release},P_{i}\rangle\) for each process in \(N_{i}\cup\{P_{i}\}\) to manage the next request for exiting the CS. Next, we explain how the liveness is guaranteed. We incorporate the timestamp mechanism proposed by [19] in our algorithm. Based on the priority of the timestamp for each request to change the state, a process preempts a permission when necessary, as proposed in [11; 20; 21]. The proposed algorithm uses \(\langle\mathsf{Preempt},P_{i}\rangle\) and \(\langle\mathsf{Relinquish},P_{i}\rangle\) messages for this purpose. In the proposed algorithm, each process \(P_{i}\) maintains the following local variables. * \(state_{i}\): The current state of \(P_{i}\): \(\mathsf{InCS}\) or \(\mathsf{OutCS}\). * \(ts_{i}\): The current value of the logical clock [19]. * \(nGrants_{i}\): The number of grants that \(P_{i}\) obtains for exiting the CS. * _grantedTo_: A set of timestamps \((ts_{j},P_{j})\) for the requests to \(P_{j}\)'s exiting the CS that \(P_{i}\) has been granted, but that \(P_{j}\) has not yet released. * _pendingReq_: A set of timestamps \((ts_{j},P_{j})\) for the requests to \(P_{j}\)'s exiting the CS that are pending. * _preemptingNow_: A process id \(P_{j}\) such that \(P_{i}\) preempts a permission for \(P_{j}\)'s exiting the CS if the preemption is in progress. For each request, a pair \((ts_{i},P_{i})\) is used as its timestamp. We implicitly assume that the value of the logical clock [19] is attached to each message exchanged. Thus, in the proposed algorithm, we omit a detailed description of the maintenance protocol for \(ts_{i}\). The timestamps are compared as follows: \((ts_{i},P_{i})<(ts_{j},P_{j})\) iff \(ts_{i}<ts_{j}\) or \((ts_{i}=ts_{j})\wedge(P_{i}<P_{j})\). Formal description of the proposed algorithm for each process \(P_{i}\) is presented in Algorithms 1 and 2. When each process \(P_{i}\) receives a message, it invokes a corresponding message handler. Each message handler is executed atomically. That is, if a message handler is being executed, the arrival of a new message does not interrupt the message handler. In this algorithm description, we use the statement wait until (conditional expression). By this statement, a process is blocked until the conditional expression is true. While a process is blocked by the wait until statement and it receives a message, it invokes a corresponding message handler. ```
\(state_{i}\in\{\mathsf{InCS},\mathsf{OutCS}\}\), initially\(state_{i}=\left\{ \begin{array}{ll}\mathsf{InCS}&(P_{i}\in\mathcal{CS}(C_{0}))\\ \mathsf{OutCS}&(P_{i}\
ot\in\mathcal{CS}(C_{0}))\end{array}