Distributed Algorithms for Message-Passing Systems