Message Passing
摘要
All previously introduced programming language constructions synchronize processes by accessing shared variables, i.e., they require shared memory. For distributed applications, however, a paradigm is needed in which processes are not dependent on that: communication by message passing. The chapter begins with the introduction of channels and the definition of synchronous and asynchronous message passing and simple examples and elegant applications of these concepts: the construction of semaphores, bounded buffers and networks of filters. Then “selective waiting” is introduced, which gives message passing the expressiveness of all other synchronization constructs and enables the introduction of the client-server paradigm. In Go, “guarded selective waiting” can also be realized, which contributes greatly to the clarity of algorithms. Both concepts are again illustrated by many examples known from the previous chapters. The chapter concludes with the proof of the equivalence of the expressiveness of the semaphore concept and message passing and a concise comparison of the language means of the monitor concept and the client-server paradigm.