Block 2: Interprocess Communications - PowerPoint PPT Presentation

Loading...

PPT – Block 2: Interprocess Communications PowerPoint presentation | free to download - id: 1377e7-MDUwN



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Block 2: Interprocess Communications

Description:

... loop to repeatedly issue a receive operation until the awaited data is received. ... One side issues a request and awaits a response from the other side. ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 48
Provided by: jsa132
Learn more at: http://www.cems.uwe.ac.uk
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Block 2: Interprocess Communications


1
Block 2 Interprocess Communications
  • Jin Sa

2
Outline of block 2
  • Characteristics of IPC
  • Unicast and multicast
  • Operations in IPC
  • Event synchronisation
  • Synchronous and asynchronous
  • Event diagram
  • Deadlocks and timeout
  • Data representation and data marshalling
  • External representation
  • Data marshalling and unmarshalling
  • Text-based protocols

3
Interprocess Communications
  • The backbone of distributed computing is
    interprocess communications (IPC).
  • Distributed computing requires information to be
    exchanged among independent processes.
  • In distributed computing, two or more processes
    engage in IPC in a protocol agreed upon by the
    processes. A process may be a sender at some
    points during a protocol, a receiver at other
    points.

4
Interprocess Communications in Distributed
Computing
5
Characteristics of IPC
6
IPC unicast and multicast
  • When communication is from one process to a
    single other process, the IPC is said to be a
    unicast. When communication is from one process
    to a group of processes, the IPC is said to be a
    multicast. In this semseter, We will be mainly
    concerned with unicast.

7
Unicast vs. Multicast
8
Operations provided in Interprocess
Communications API
  • Send transmitting data to a receiving process
  • Receive accept data from a sending process
  • Connect establish a logical connection between
    two processes. The sending process issues a
    request for connection, the other process issues
    an accept connection operation
  • Disconnect de-allocate a previously established
    connection at both sides

9
Interprocess Communication in basic HTTP
10
Event Synchronization
  • Interprocess communication requires that the two
    processes synchronize their operations one side
    sends, then the other receives until all data has
    been sent and received.
  • The synchronization requires system support.

11
Synchronous vs. asynchronous Communication
  • The IPC operations may provide the
    synchronization necessary using blocking. A
    blocking operation issued by a process will block
    further processing of the process until the
    operation is fulfilled.
  • Alternatively, IPC operations may be asynchronous
    or nonblocking. An asynchronous operation issued
    by a process will not block further processing of
    the process. Instead, the process is free to
    proceed with its processing, and may optionally
    be notified by the system when the operation is
    fulfilled.

12
Synchronous send and receive
Event diagram
13
Asynchronous send and synchronous receive
14
Synchronous send and async. receive - 1
15
Synchronous send and async. receive - 1
  • The data requested by the receive operation has
    already arrived at the time the receive operation
    is issued. In this case, the data is delivered to
    process 2 immediately, and an acknowledgement
    from host 2s IPC facility will unblock process 1.

16
Synchronous send and async. receive - 2
17
Synchronous send and async. receive - 2
  • The data requested by the receive operation has
    not yet arrived. Process 1 is blocked
    indefinitely until process 2 reissue a receive
    request and an acknowledgement arrives from host
    2s IPC facility.
  • It is common to use a loop to repeatedly issue a
    receive operation until the awaited data is
    received.

18
Synchronous send and async. receive - 3
19
Synchronous send and async. receive - 3
  • The data requested by the receive operation has
    not yet arrived. Host 2 IPC facility will notify
    process 2 when the data arrives.
  • This scenarios requires process 2 provide a
    listener that can be invoked by the IPC facility
    to notify the process of the arrival of the data.

20
Deadlocks and Timeouts
  • Operations can result in indefinite blocking
  • For example, a blocking connect request can
    result in the requesting process to be suspended
    indefinitely if the connection is unfulfilled or
    cannot be fulfilled, perhaps as a result of a
    breakdown in the network .
  • It is generally unacceptable for a requesting
    process to hang indefinitely. Indefinite
    blocking can be avoided by using timeout.
  • Indefinite blocking may also be caused by a
    deadlock

21
Example
  • The daytime service is the simplest network
    service, whereby a client process obtains a
    timestamp (the time of day on the server host)
    from the server process.
  • Is it possible for a daytime client to be blocked
    indefinitely? Explain your answer.
  • yes, if after issuing a block receive operation,
    server does not respond and there is no time out
    defined.

22
Indefinite blocking due to a deadlock
23
Event diagram
  • Event diagram can be used to document the
    detailed sequence of events and blocking during
    the of a protocol.
  • The execution of each process with respect to
    time is represented using a vertical line.
  • A solid line interval represents a period that
    the process is active.
  • A broken line interval represents the process is
    blocked.

24
In class exercisesQuestion1
  • Q1Process A sends a single message to process B
    using connectionless IPC. To do so, A issues a
    send operation (specifying the message as
    argument) sometime during its execution, and B
    issues a receive operation. Suppose the send
    operation is blocking and the receive operation
    is non-blocking. Draw an event diagram for each
    of the following scenario

25
In class exercisesQuestion 1 cont.
  • Process A issues its send operation prior to
    process B issues its receive operation.
  • Process B issues its receive operation prior to
    process A issues its send operation.

26
Question 1 answer
  • The data requested by the receive operation has
    already arrived, the data is delivered to process
    B and an acknowledgement from host 2s IPC
    facility will unblock process A subsequently.

27
Question 1 answer
  • The data requested by the receive operation has
    not yet arrived, no data is delivered to the
    process. It is the receiving process
    responsibility to ascertain that it has indeed
    received the data and, if necessary, repeat the
    receive operation until the data has arrived.
    Process 1 is blocked indefinitely until process 2
    reissues a receive request and an acknowledgement
    eventually arrives from host 2s IPC facility.

28
Question 1 answer
  • The data requested by the receive operation has
    not yet arrived. The IPC facility of host 2 will
    notify process 2 when the data it requested has
    arrived, at which point process 2 may proceed to
    process the data. This scenario requires that
    process 2 provides a listener or event handler
    which can be invoked by the IPC facility to
    notify the process of the arrival of the
    requested data.

29
Question 2
  • Q2 Repeat the last question. This time both
    operations (send, receive) are blocking.
  • Process A issues its send operation prior to
    process B issues its receive operation
  • Process B issues its receive operation prior to
    process A issues its send operation.

30
Question 2 answer
31
Question 2 answer
32
Question 3
  • Three processes P1, P2, P3 are engaged in
    interprocess
  • At time 1, P3 issues a receive from P2.
  • At time 2, P1 sends m1 to P2.
  • At time 3, P2 issues a receive from P1.
  • At time 4, P2 receives m1.
  • At time 5, P2 sends message m1 to P3.
  • At time 6, P3 receives m1 P1 issues receive
    from P2.
  • At time 7, P2 issues a receive from P3.
  • At time 8, P3 sends m2 to P2.
  • At time 9, P2 receives m2.
  • At time 10, P2 sends m2 to P1.
  • At time 11, P1 receives m2.
  • Draw a time event diagram for P1, P2 and P3 to
    show the sequence of events. All operations are
    blocking.

33
Question 3 answer
34
Notes
  • In a system environment such as Java, which
    supports multithreading, the blocking receive has
    no disadvantages as it can issue a separate
    thread to handle the blocking receive, and the
    other threads remain active.
  • Non-blocking receive appears to be more
    efficient, but it requires extra complexity in
    the receiving process.
  • Many todays systems do not generally provide the
    non-blocking receive operation.

35
Data Representation and Data Marshalling
36
External data representation and marshalling
  • Information stored in a running program is
    represented as data structures.
  • Data transmitted on the network is sequence of
    bytes.
  • Therefore data structures must be flattened, i.e.
    convert to sequence of bytes. Before transmission
    and rebuilt on arrival.

37
External data representation and marshalling
  • Different computers may store primitive values in
    different formats.
  • To enable any two computers to exchange binary
    values (e.g. to support RPC)
  • The values are converted to an agreed external
    format before transmission and converted to the
    local form on arrival
  • The values are sent in the senders format, and
    receiver converts the value is necessary.
  • External representation an agreed standard for
    the representation of data structures and
    primitive values.

38
External data representation and marshalling
  • Marshalling is the process of taking a collection
    of data items and put them into a form suitable
    for transmission in a message. Unmarshalling is
    the process of disassembling them on arrival to
    produce an equivalent collection of data items at
    the destination.
  • Marshalling consists of the translation of
    structured data items and primitive values into
    an external data representation. Unmarshalling
    consists of the generation of primitive values
    from their external data representation and the
    rebuild of the data structure.

39
Examples of external data representation
  • CORBAs common data representation
  • Javas object serialization
  • XML a text-based markup language that is fast
    becoming the standard for data interchange on the
    Web.

40
Sample XML file
  • XML has syntax similar to HTML.
  • Unlike HTML, XML tags tell you what the data
    means
  • Example
  • ltmessagegt
  • lttogtyou_at_yourAddress.comlt/togt
    ltfromgtme_at_myAddress.comlt/fromgt
  • ltsubjectgt What is XML lt/subjectgt
  • lttextgt XML is lt/textgt
  • lt/messagegt

41
Client-server communication
  • The IPC form of communication is designed to
    support roles and message exchanges in typical
    client-server interaction, where there is a
    request-reply communication.

42
Protocol
  • In a distributed application, two processes
    perform interprocess communication in a mutually
    agreed upon protocol.
  • The specification of a protocol should include
  • (i) the sequence of data exchange, which can be
    described using a time event diagram.
  • (ii) the specification of the format of the data
    exchanged.

43
Request-reply protocols
  • An important type of protocol is request-reply
    protocol
  • One side issues a request and awaits a response
    from the other side.
  • The protocl proceeds in an iteration of
    request-response until the task is complete.
  • Popular network protocols, including FTP (File
    Transfer Protocol) and HTTP, are request-response
    protocols.

44
HTTP A sample protocol
  • The Hypertext Transfer Protocol is a protocol for
    a process (the browser) to obtain a document from
    a web server process.
  • It is a request-response protocol a browser
    sends a request to a web server process, which
    replies with a response.

45
HTTP session
  • In its basic form, HTTP is a text-based,
    request-response protocol that calls for only one
    round of exchange of messages.
  • A web server process constantly listens for
    incoming request.
  • A web browser process makes a connection to the
    web server process, then issues a request.
  • The server processes the request and dispatches a
    response include the document requested by the
    browser.
  • The browser process then parses the response and
    displays the document.

46
Question 4
  • In the context of IPC, what is meant by data
    marshaling? (There are two components to data
    marshalling name and describe each.) Why is it
    necessary?
  • Answer
  • The two components of data marshaling are
  • Data structures used in programming need to be
    flattened or serialized, since data transmitted
    over the network must be serialized.
  • The data needs to be converted to an external
    representation so that it may be interpreted
    correctly by the receiver, which then maps the
    external representation to its local
    representation.

47
Review questions
  • On completion of block 2, you should be able to
  • Know the operations in IPC
  • understand event synchronisation
  • draw event diagrams to illustrate the events
  • understand the concept of deadlock and timeout
  • understand data marshalling
About PowerShow.com