Chapter IV Interprocess Communication Jehan-François Pâris

Slides:



Advertisements
Similar presentations
Switching Techniques In large networks there might be multiple paths linking sender and receiver. Information may be switched as it travels through various.
Advertisements

Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Lecture 3 Page 1 CS 239, Spring 2001 Interprocess Communications in Distributed Operating Systems CS 239 Distributed Operating Systems April 9, 2001.
1 Java Networking – Part I CS , Spring 2008/9.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
CS 582 / CMPE 481 Distributed Systems Communications (cont.)
Computer Science Lecture 2, page 1 CS677: Distributed OS Last Class: Introduction Distributed Systems – A collection of independent computers that appears.
William Stallings Data and Computer Communications 7 th Edition (Selected slides used for lectures at Bina Nusantara University) Transport Layer.
Distributed systems (NET 422) Prepared by Dr. Naglaa Fathi Soliman Princess Nora Bint Abdulrahman University College of computer.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
Chapter 4.1 Interprocess Communication And Coordination By Shruti Poundarik.
Gursharan Singh Tatla Transport Layer 16-May
Switching Techniques Student: Blidaru Catalina Elena.
What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best.
Process-to-Process Delivery:
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Chapter 9 Message Passing Copyright © Operating Systems, by Dhananjay Dhamdhere Copyright © Operating Systems, by Dhananjay Dhamdhere2 Introduction.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
The Transmission Control Protocol (TCP) Application Services (Telnet, FTP, , WWW) Reliable Stream Transport (TCP) Connectionless Packet Delivery.
User Datagram Protocol (UDP) Chapter 11. Know TCP/IP transfers datagrams around Forwarded based on destination’s IP address Forwarded based on destination’s.
Chapter 4: Interprocess Communication‏ Pages
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 3: Processes.
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Networking Basics CCNA 1 Chapter 11.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
 Communication Distributed Systems IT332. Outline  Fundamentals  Layered network communication protocols  Types of communication  Remote Procedure.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765.
Distributed (Operating) Systems -Communication in Distributed Systems- Computer Engineering Department Distributed Systems Course Assoc. Prof. Dr. Ahmet.
Remote Procedure Call RPC
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
Distributed systems (NET 422) Prepared by Dr. Naglaa Fathi Soliman Princess Nora Bint Abdulrahman University College of computer.
Remote Procedure Call and Serialization BY: AARON MCKAY.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
4343 X2 – The Transport Layer Tanenbaum Ch.6.
Implementing Remote Procedure Call Landon Cox February 12, 2016.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Network Communications A Brief Introduction. 2 Network Communications.
R Some of these slides are from Prof Frank Lin SJSU. r Minor modifications are made. 1.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Remote Procedure Calls
The Transport Layer Implementation Services Functions Protocols
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Prof. Leonardo Mostarda University of Camerino
5. End-to-end protocols (part 1)
Switching Techniques In large networks there might be multiple paths linking sender and receiver. Information may be switched as it travels through various.
Sarah Diesburg Operating Systems COP 4610
Process-to-Process Delivery:
Switching Techniques.
EECE.4810/EECE.5730 Operating Systems
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Last Class: Communication in Distributed Systems
Presentation transcript:

Chapter IV Interprocess Communication Jehan-François Pâris

Chapter overview Types of IPC –Message passing –Shared memory Message passing –Blocking/non-blocking, … –Datagrams, virtual circuits, streams –Remote procedure calls

Message passing (I) Processes that want to exchange data send and receive messages Any message exchange requires – One send send(addr, msg, length); – One receive receive(addr, msg, length);

Message passing (II) Receiver msg receive(…) send(…) Sender

Advantages Very general –Sender and receivers can be on different machines Relatively secure –Receiver can inspect the messages it has received before processing them

Disadvantages Hard to use –Every data transfer requires a send() and a receive() –Receiving process must expect the send() Might require forking a special thread

Shared Memory Name says it –Two or more processes share a part of their address space Process P Process Q same

Advantages Fast and easy to use –The data are there but –Some concurrent accesses to the shared data can result into small disasters –Must synchronize access to shared data Topic will be covered in next chapter

Disadvantages Not a general solution –Sender and receivers must be on the same machine Less secure –Processes can directly access a part of the address space of other processes

MESSAGE PASSING Defining issues –Direct/Indirect communication –Blocking/Non-blocking primitives –Exception handling –Quality of service Unreliable/reliable datagrams Virtual circuits, streams

Direct communication (I) Send and receive system calls always specify processes as destination or source: –send(process, msg, length); –receive(process, msg, &length); Most basic solution because there is –No intermediary between sender and receiver

An analogy Phones without switchboard –Each phone is hardwired to another phone

Direct communication (II) Process executing the receive call must know the identity of all processes likely to send messages – Very bad solution for servers Servers have to answer requests from arbitrary processes

Indirect communication (I) Send and receive primitives now specify an intermediary entity as destination or source: the mailbox send(mailbox, msg, size); receive(mailbox, msg, &size); Mailbox is a system object created by the kernel at the request of a user process

An analogy (I) Phones with a switchboard –Each phone can receive calls from any other phone

An analogy (II) Each phone has now a phone number –Callers dial that number, not a person’s name Taking our phone with us allows us to receive phone calls from everybody

Indirect communication (II) Different processes can send messages to the same mailbox –A process can receive messages from processes it does not know anything about –A process can wait for messages coming from different senders Will answer the first message it receives

Mailboxes Mailboxes can be – Private Attached to a specific process – Think of your cell phone – Public System objects – Think of a house phone

Private mailboxes Process that requested its creation and its children are the only processes that can receive messages through the mailbox are that process and its children Cease to exist when the process that requested its creation (and all its children) terminates. Often called ports Example : BSD sockets

Public mailboxes Owned by the system Shared by all the processes having the right to receive messages through it Survive the termination of the process that requested their creation Work best when all processes are on the same machine Example: System V UNIX message queues

Blocking primitives (I) A blocking send does not return until the receiving process has received the message –No buffering is needed – Analogous to what is happening when you call somebody who does not have voice mail

Blocking primitives (II) A blocking receive does not return until a message has been received Like waiting by the phone for an important message or staying all day by your mailbox waiting for the mail carrier

Blocking primitives (III) Receiver send(…) Sender receive(…)

Non-blocking primitives (I) A non-blocking send returns as soon as the message has been accepted for delivery by the OS –Assumes that the OS can store the message in a buffer. – Like mailing a letter: once the letter is dropped in the mailbox, we are done. The mailbox will hold your letter until a postal employee picks it up

Non-blocking primitives (II) A non-blocking receive returns as soon as it has either retrieved a message or learned that the mailbox is empty – Like checking whether your mail has arrived or not

Buffer Non-blocking primitives (III) Receiver msg receive(… acts as a retrieve(…) send(…) Sender

Simulating blocking receives Can simulate a blocking receive with a non-blocking receive within a loop: do { code = receive(mbox,msg,size); sleep(1); // delay } while (code == EMPTY_MBOX); –Known as a busy wait

Simulating blocking sends Can simulate a blocking send with two non-blocking sends and a blocking receive-: –Sender sends message and requests an acknowledgement(ACK) –Sender waits for ACK from receiver usign a blocking receive –Receiver sends ACK

The standard choice In general we prefer – Indirect naming – Non-blocking sends Sender does not care about what happens once the message is sent Similar to UNIX delayed writes – Blocking receives Receiver needs the data to continue

Buffering Non-blocking primitives require buffering to let OS store somewhere messages that have been sent but not yet received These buffers can have – Bounded capacity Refuse to receive messages when the buffer is full –Theoretically unlimited capacity.

An explosive combination (I) Blocking receive does not go well with direct communication –Processes cannot wait for messages from several sources without using special parallel programming constructs: Dijkstra's alternative command

An explosive combination (II) Using blocking receives with direct naming does not allow the receiving process to receive any messages from any process but the one it has specified Q R S P receive(Q, message) X X

Exception condition handling Must specify what to do if one of the two processes dies –Especially important whenever the two processes are on two different machines Must handle – Host failures – Network partitions

Quality of service When sender and receiver are on different machines, messages –Can be lost, corrupted or duplicated –Arrive out of sequence Can still decide to provide reliable message delivery

Positive Acknowledgments Basic technique for providing reliable delivery of messages Destination process sends an acknowledgment message (ACK) for every message that was correctly delivered –Damaged messages are ignored Sender resends any message that has not been acknowledged within a fixed time frame

First Scenario Send ACK Send message Sender Receiver

Second Scenario Receiver Send message Message is lost: no ACK is sent Resend message Sender X

Third Scenario (I) Send ACK Send message Receiver ACK is lost Resend message X Sender

Third Scenario (II) Receiver must acknowledge a second time the message –Otherwise it would be resent one more time Rule is – Acknowledge any message that does not need to be resent!

Classes of service Datagrams: –Messages are send one at time Virtual circuits: –Ordered sequence of messages – Connection-oriented service Streams : –Ordered sequence of bytes –Message boundaries are ignored

Datagrams Each message is sent individually –Some messages can be lost, other duplicated or arrive out of sequence – Equivalent of a conventional letter Reliable datagrams: resent until they are acknowledged Unreliable datagrams

Unreliable datagrams (I) Messages are not acknowledged Works well when message requests a reply –Reply is implicit ACK of message Server Send request Client Send reply (and ACK request)

Unreliable datagrams (II) Exactly what we do in real life: – We rarely ACK s and other messages – We reply to them! Sole reason to ACK a request is when it might take a long time to reply to it

UDP User Datagram Protocol Best known datagram protocol Provides an unreliable datagram service –Messages can be lost, duplicated or arrive out of sequence Best for short interactions –One request and one reply

Virtual circuits (I) Establish a logical connection between the sender and the receiver Messages are guarantee d to arrive in sequence without lost messages or duplicated messages – Analogous to the words of a phone conversation

Virtual circuits (II) Require setting up a virtual connection before sending any data –Costlier than datagrams Best for transmitting large amounts of data that require sending several messages – File transfer protocol (FTP) – Hypertext transfer protocol (HTTP)

Streams Like virtual circuits Do not preserve message boundaries: –Receiver sees a seamless stream of bytes Offspring of UNIX philosophy –Record boundaries do not count –Message boundaries should not count

TCP Transmission Control Protocol Best known stream protocol Provides a reliable stream service Said to be heavyweight –Requires three messages ( packets ) to establish a virtual connection

Datagrams and Streams Datagrams: –Unreliable –Not ordered –Lightweight –Deliver messages Example: –UDP Streams: –Reliable –Ordered –Heavyweight –Stream-oriented Example: –TCP

REMOTE PROCEDURE CALLS Apply to client-server model of computation A typical client-server interaction: send_req(args); rcv_req(&args); process(args, &results); send_reply(results); rcv_reply(&results);

RPC (cont’d) Very similar to a procedure call to a procedure: xyz(args, &results);xyz(...) { …. return;...} // xyz Try to use the same formalism

RPC (cont’d) We could write rpc(xyz, args, &results);xyz(...) { …. return;...} // xyz and let system take care of all message passing details

Advantages Hides all details of message passing –Programmer can focus on the logic of her application Provides a higher level of abstraction Extends a well-known model of programming –Anybody that can use procedures and function can quickly learn to use remote procedure calls

Disadvantage The illusion is not perfect –RPCs do not always behave exactly like regular procedure calls Client and server do not share the same address space Programmer must remain aware of these subtle and not so subtle differences

General Organization Server Procedure User Stub calls Server Stub User Program (system generated)

What the programmer sees Server Procedure Does a RPC User Program All IPC between client and server are hidden

The user program Contains the user code Calls the user stub rpc(xyz, args, &results); Appears to call the server procedure

The user stub Procedure generated by RPC package: –Packs arguments into request message and performs required data conversions ( argument marshaling ) –Sends request message –Waits for server's reply message –Unpacks results and performs required data conversions ( argument unmarshaling )

The server stub Generic server generated by RPC package: –Waits for client requests –Unpacks request arguments and performs required data conversions –Calls appropriate server procedure –Packs results into reply message and performs required data conversions –Sends reply message

The server procedure Procedure called by the server stub Written by the user Does the actual processing of user requests

Differences with regular PC Client and server processes do not share the same address space Client and server can be on different machines Must handle partial failures

No shared address space This means – No global variables – Cannot pass addresses Cannot pass arguments by reference Cannot pass dynamic data structures through pointers

The solution RPC can pass arguments by value and result –Pass the current value of the argument to the remote procedure – Copy the returned value in the user program Not the same as passing arguments by reference

Passing by reference Caller: … i = 0; abc(&i); … i abc(int *k){ (*k)++; } Procedure abc( ) will directly increment variable i

i = 1 i = 0 Passing by value and result Caller: … i = 0; abc(&i); … i abc(int *k){ (*k)++; } Variable i is increased after caller receives server’s reply

An example (I) Procedure doubleincrement doubleincrement(int *p,int *q) { (*p)++ ; (*q)++ ; } // doubleincremen t Calling doubleincrement(&m, &m); should increment m twice

An example (II) Calling doubleincrement(&m, &m); passing arguments by value and return only increments m once Let us consider the code fragment int m = 1; doubleincrement(&m, &m);

Passing by reference Caller: … int m = 1; doubleincrement(&m,&m); … ; m Pass TWICE the ADDRESS of m Variable m gets incremented TWICE

Passing by value and result Caller: … int m = 1; doubleincrement(&m,&m); … ; m Pass twice the VALUE of m: 1 and 1 Return NEW VALUES: 2 and 2

Passing dynamic types (I) Cannot pass dynamic data structures through pointers Must send a copy of data structure For a linked list –Send array with elements of linked list plus unpacking instructions

Passing dynamic types (II) We want to pass We send to the remote procedure Header identifies linked list with four elements A ABCD NIL ABCDLL4

The NYC Cloisters Rebuilt in NYC from actual cloister stones

Architecture considerations The machine representations of floating point numbers and byte ordering conventions can be different: – Little endians start at the least significant byte: Intel's 80x86 including Pentium – Big-endians start at the most significant byte: Sun’s SPARC and most RISC processors

The solution Define a network order and convert all numerical variables to that order –Use hton family of functions – Same as requiring all air traffic control communications to be in English

Detecting partial failures The client must detect server failures –Can send are you alive? messages to the server at fixed time intervals – That is not hard!

Handling partial executions Client must deal with the possibility that the server could have crashed after having partially executed the request –ATM machine calling the bank computer Was the account debited or not?

First solution (I) Ignore the problem and always resubmit requests that have not been answered –Some requests may be executed more than once Will work if all requests are idempotent –Executing them several times has the same effect as executing them exactly once

First solution (II) Examples of idempotent requests include: –Reading n bytes from a fixed location NOT reading next n bytes –Writing n bytes starting at a fixed location NOT writing n bytes starting at current location Technique is used by all RPCs in the Sun Microsystems’ Network File System (NFS)

Second solution Attach to each request a serial number –Server can detect replays of requests it has previously received and refuse to execute them – At most once semantics Cheap but not perfect –Some requests could end being partially executed

Third solution Use a transaction mechanism –Guarantees that each request will either be fully executed or have no effect – All or nothing semantics Best and costliest solution Use it in all financial transactions

An example Buying a house using mortgage money –Cannot get the mortgage without having a title to the house –Cannot get title without paying first previous owners –Must have the mortgage money to pay them Sale is a complex atomic transaction

Realizations (I) Sun RPC: –Developed by Sun Microsystems –Used to implement their Network File System MSRPC (Microsoft RPC): –Proprietary version of the DCE/RPC protocol –Was used in the Distributed Component Object Model (DCOM).

Realizations (II) SOAP: –Exchanges XML-based messages –Runs on the top of HTTP Very portable Also very verbose