A Comparison of Two IPC Mechanisms

Marc Horowitz

Section 4: Prof. Peter Elias Luis Rodriguez February 19, 1991

The IPC mechanism in Mach, called the “port,” differs in several significant ways from the traditional RPC call, such as LRPC. In a traditional RPC, a transaction consists of a client sending a message to a server, and the server sending a response back to the client. In Mach, a transaction consists of a task sending a message to a port. If there is a response from the receiving task, this is a separate transaction. So the Mach port mechanism is one-sided, which provides for asynchronous systems. (It was noted in lecture that the RPC mechanism we are using has synchronicity imposed on it for simplicity, and that it is not intrinsic to the mechanism.) Another major difference is that Mach ports do not require copying of data from the sender’s address space to the recipient’s address space. The IPC mechanism takes advantage of the copy-on-write capabilities of the Mach virtual memory system to give the recipient a writeable copy of the message, without copying the data until it is actually modified. This means large messages can be sent with no loss of efficiency.

It would be possible to implement LRPC on top of Mach ports in such a way that any code which used LRPC would function on the emulated system, although with very different operational details. Calls between hosts would require adding additional functionality (perhaps a port interface to a network) in order to make RPC calls between hosts. In the LRPC mechanism, a client makes a protected call to a server, which receives the arguments, possibly modifying them, and returning a value or values. A Mach port implementation of this system use a similar approach to the LRPC system. A compiler could generate stubs, which would consist of a call to send a message to the server, and a call to block waiting for a response from the server. If the call was pass-by-reference, the stub would have to copy the data from the server’s response to the client’s call. On the other side, the server stub would have to set up pointers into the received message for the server’s real routine to read and possibly modify, then send the response back to the client’s port. If it is not required to use only ports, it would be advantageous to message only the pass-by-value arguments, and to set up appropriate shared memory segments for pass-by-reference arguments. This would mean that an RPC could be performed in all cases without ever copying arguments or return values.

In conclusion, Mach primitives provide a substantially different implementation of IPC than we have previously seen. However, this difference is only in the implementation, as it can be used exactly as the RPC’s with which we are already familiar.