In this paper, we propose several deadlock-free protocols for implementing the generalized alternative construct, where a process non-deterministically chooses between sending or receiving among various synchronous channels. We consider general many-to-many channels and examine in detail the special case of fan (many-toone and one-to-many) channels, which are common and can be implemented much more efficiently. We propose a protocol that achieves an optimal number of message cycles per user-level communication, significantly improving on previous results. We propose several other "less aggressive" protocols, which may be more suitable for some applicationsand networks, and demonstrate how to adaptively switch between them and modify protocol parameters.
Erik D. Demaine