1Message-Passing&Remote Procedure Call2Interprocess Communication -Messages• Assume no explicit sharing of data elements in the address spaces of processes wishing to cooperate/communicate.• Essence of message-passing is copying(although implementations may avoid actual copies whenever possible). • Problem-solving with messages - has a feel of more active involvement by participants.3Issues• System calls for sending and receiving messages with the OS(s) acting as courier.– Variations on exact semantics of primitives and in the definition of what comprises a message.• Naming - direct (to/from pids), indirect (to distinct objects - e.g., mailboxes, ports, sockets)– How do unrelated processes “find” each other?• Buffering - capacity and blocking semantics.• Guarantees -in-order delivery? no lost messages?4Send and Receive5Client / Serverserver->6Example: Time Service7Example: Time Service via Messages8Client / Server with Threads9UNIX Sockets for Client/ Server Message PassingServer1. Create a named socketsyscalls:sfd = socket(…)bind (sfd, ptr,len)2. Listen for clientslisten(sfd,numpend)4. Connection made and continue listeningcfd=accept(sfd, …)5. Exchange datawrite(cfd, …)6. Done: close(cfd);7. Really done: close(sfd);Client3. Create unnamed socket & ask for connectionsyscalls:cfd=socket(…)err=connect(cfd, ptr, …)5. Exchange dataread(cfd, …)6. Done: close(cfd);namenameIn a child process of server10Hiding Message-Passing: RPC18Example: Time Service via RPC19What’s Really Going On20RPC
View Full Document