• Tidak ada hasil yang ditemukan

IPC – unicast and multicast

N/A
N/A
Protected

Academic year: 2019

Membagikan "IPC – unicast and multicast"

Copied!
37
0
0

Teks penuh

(1)

Interprocess

Distributed Computing, M.

L.

Liu

(2)

Interprocess Communications

- Operating systems provide facilities for interprocess

i i (IPC) h

communications (IPC), such as message queues, semaphores, and shared memory.

Distributed computing systems make use of these

- Distributed computing systems make use of these

facilities to provide application programming

interface which allows IPC to be programmed at a higher level of abstraction.

- Distributed computing requires information to be

exchanged among independent processes

Distributed Computing, M. L. Liu

2

(3)

IPC – unicast and multicast

z 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 processes. A process may be a sender at some

points during a protocol, a receiver at other points.

z When communication is from one process to a

z 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

f th IPC i id t b l i

group of processes, the IPC is said to be a multicast,

a topic that we will explore in a later chapter.

Distributed Computing, M. L. Liu

(4)

Unicast vs. Multicast

P2 P

2 P3

...

P4

m

m m m

P1 P

P1 P

1

unicast

multicast

Distributed Computing, M. L. Liu

4

(5)

Interprocess Communications in

Di

ib

d C

i

Distributed Computing

Process 1 Process 2

Process 1 Process 2

data data

sender receiver

Distributed Computing, M. L. Liu

(6)

Operations provided in an archetypal

p

p

yp

Interprocess Communications API

• Receive ( [sender], message storage object)( [ ], g g j )

• Connect (sender address, receiver address), for

connection-oriented communication.

• Send ( [receiver], message)

• Disconnect (connection identifier), for connection-( ),

oriented communication.

Distributed Computing, M. L. Liu

(7)

Interprocess Communication in basic HTTP

Web server

S3 S4

a proce ss

ope rations:

S1: acce pt conne ction S2: re ce ive (re que st)

an ope ration

data flow

S3: se nd (re sponse ) S3: disconne ct

C 1: make conne ction

C 4: disconne ct C 3

Distributed Computing, M. L. Liu

(8)

Event Synchronization

z 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.

d ll h d i b f h i

z Ideally, the send operation starts before the receive

operation commences.

I ti th h i ti i t

z In practice, the synchronization requires system

support.

Distributed Computing, M. L. Liu

(9)

Synchronous vs. Asynchronous

Communication

z The IPC operations may provide the synchronization

necessary using blocking. A blocking operation issued by

a process will block further processing of the process a process will block further processing of the process until the operation is fulfilled.

z Alternatively, IPC operations may be asynchronous or y p y y

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 Instead, the process is free to proceed with its processing, and may optionally be notified by the system when the operation is fulfilled.

Distributed Computing, M. L. Liu

(10)

Synchronous send and receive

process 1 running on host 1

process 2 running on host 2

blocking send starts

blocking receive starts

an operation b oc g se d sta ts

blocking send returns blocking receive ends

execution flow

suspended period a ope at o

acknowledgement of data received provided by the IPC facility

Synchronous Send and Receive

Distributed Computing, M. L. Liu

(11)

Asynchronous send and synchronous

receive

Process 1

Process 2

blocking receive starts

nonblocking send

operation

blocking receive returns

execution flow

suspended period operation

Asynchronous Send and Synchronous Receive

Distributed Computing, M. L. Liu

(12)

Synchronous send and Async. Receive - 1

Process 1

Process 2

blocking send issued

nonblocking receive issued

execution flow suspended period transparent acknowledgement

provided by the IPC facility

Synchronous Send and Asynchronous Receive

Scenario A

Distributed Computing, M. L. Liu

(13)

Synchronous send and Async. Receive - 2

Process 1

Process 2

nonblocking receive issued and returned immediately blocking send issued

indefinite

blocking execution flow

suspended period

2

Synchronous Send and Asynchronous Receive

Scenario B Process 1

Process 2

Distributed Computing, M. L. Liu

(14)

Synchronous send and Async. Receive - 3

Process 1

Process 2

nonblocking receive issued and returned immediately blocking send issued

process is notified

execution flow suspended period p

of the arrival of data

transparent acknowledgement provided by the IPC facility

Synchronous Send and Asynchronous Receive

Scenario C

Distributed Computing, M. L. Liu

(15)

Asynchronous send and Asynchronous

receive

Process 1

Process 2

nonblocking receive issued and returned immediately blocking send issued

process is notified

execution flow suspended period p

of the arrival of data

Asynchronous Send and Asynchronous Receive

Scenario C

Distributed Computing, M. L. Liu

(16)

Event diagram

Process B Process A

Process B

request 1

time

response 1

interprocess communication

request 2

execution flow

process blocked response2

Distributed Computing, M. L. Liu

16

(17)

Blocking, deadlock, and timeouts

z Blocking operations issued in the wrong sequence can cause

deadlocks.

z Deadlocks should be avoided. Alternatively,Deadlocks should be avoided. Alternatively, timeouttimeout can be used tocan be used to detect deadlocks.

i f 2 i d

Process 1 Process 2

receive from process 2 issued

received from process 1 issued process 1 blocked pending data

from process 2.

process 2 blocked pending data from process 1.

Distributed Computing, M. L. Liu

(18)

Using threads for asynchronous IPC

Wh i IPC i i f i i i

z When using an IPC programming interface, it is important to note whether the operations are synchronous or asynchronous.

z If only blocking operation is provided for send and/or receive, then it is

th ibilit t i hild th d if

the programmer’s responsibility to using child processes or threads if asynchronous operations are desired.

process

main thread main thread

new thread issues a blocking IPC operation

th d i bl k d thread is blocked

thread is unblocked after the operation is fulfilled main thread continues with

other processing

Distributed Computing, M. L. Liu

(19)

Deadlocks and Timeouts

z Connect and receive operations can result in indefinite blocking

F l bl ki l i h

z 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 p p result of a breakdown in the network .

z It is generally unacceptable for a requesting process to

“hang” indefinitely Indefinite blocking can be avoided by “hang” indefinitely. Indefinite blocking can be avoided by using timeout.

z Indefinite blocking may also be caused by a deadlock

Distributed Computing, M. L. Liu

19

(20)

Indefinite blocking due to a deadlock

Process 1 Process 2

"receive from process 2" issued;

"receive from process 1" issued; process 1 blocked pending data

from process 2.

receive from process 1 issued; process 2 blocked pending data from process 1.

proce ss e xe cuting an ope ration

g

proce ss blocke d

Distributed Computing, M. L. Liu

(21)

Data Representation

z Data transmitted on the network is a binary stream.

z An interprocess communication system may provide the capability to allow data representation to be imposed on the raw data.

z Because different computers may have different internal storage format for the same data type, an external representation of data may be necessary.

D h lli i th f (I) fl tt i d t t t

z Data marshalling is the process of (I) flatterning a data structure,

and (ii) converting the data to an external representation.

z Some well known external data representation schemes are:

S XDR

Sun XDR

ASN.1 (Abstract Syntax Notation) XML (Extensible Markup Language)

Distributed Computing, M. L. Liu

(22)

Data Encoding Protocols

application specific data encoding language

data encoding schemes Sample Standards level of abstraction

XML:(Extensible Markup Language)

general data encoding language

network data encoding standard

ASN.1(Abstract Syntax Notation)

Sun XDR(External Data Representation)

Distributed Computing, M. L. Liu

(23)

Sample XML file

Sample XML file

http://java.sun.com/xml/docs/tutorial/overview/1_xml.html#intro

z XML is a text-based markup language that is fast

becoming the standard for data interchange on the Web.

Web.

z XML has syntax analogus to HTML.

z Unlike HTML, XML tags tell you what the data means,

rather than how to display it rather than how to display it.

z Example:

<message>

<to>you@yourAddress.com</to> <from>me@myAddress.com</from>

<subject>XML Is Really Cool</subject>

<text> How many ways is XML cool? Let me count the ways

Distributed Computing, M. L. Liu

23

<text> How many ways is XML cool? Let me count the ways... </text>

(24)

Data Marshalling

"This is a test."

1.2 7.3 -1.5

1 flattening of structured data items

110011 ... 10000100 ...

marshalling 1. flattening of structured data items 2. converting data to external (network) representation

host A

"Thi i t t "

unmarshalling 1. convert data to internal representation 2. rebuild data structures.

"This is a test."

1.2 7.3

-1.5 External to internal representation and vice versa is not required

- if the two sides are of the same host type; - if the two sides negotiates at connection.

Distributed Computing, M. L. Liu

24

(25)

Text-based protocols

z Data marshalling is at its simplest when the data

exchanged is a stream of characters, or text.

z Exchanging data in text has the additional advantage

z Exchanging data in text has the additional advantage

that the data can be easily parsed in a program and displayed for human perusal. Hence it is a popular practice for protocols to exchange requests and

practice for protocols to exchange requests and responses in the form of character-strings. Such protocols are said to be text-based.

M l t k t l i l di FTP (Fil

z Many popular network protocols, including FTP (File

Transfer Protocol), HTTP, and SMTP (Simple Mail Transfer Protocol), are text-based.

Distributed Computing, M. L. Liu

(26)

Event diagram for a protocol session

Process 1

Process 2

request 1

time

request 1

response 1

interprocess communication

request 2

execution flow process blocked

E di f l

response2

Distributed Computing, M. L. Liu

26

(27)

Event Diagram for a HTTP session

web server web browser

t i i 3 t

request request is a message in 3 parts:

- <command> <document adddress> <HTTP version> - an optional header

- optional data for CGI data using post method

response response is a message consisting of 3 parts:

- a status line of the format <protocol><status code><description> - header information which may span several lines; header information, which may span several lines;

- the document itself.

Distributed Computing, M. L. Liu

(28)

Sequence Diagram

Process A Process B

request 1

response 1 response 1

request 2

interprocess communication

response 2

Distributed Computing, M. L. Liu

(29)

sequence diagram for a HTTP session

Process A Process B

request 1

response 1 response 1

request 2

interprocess communication

response 2

Distributed Computing, M. L. Liu

(30)

Protocol

z In a distributed application, two processes perform

interprocess communication in a mutually agreed upon protocol.

z The specification of a protocol should include (i)

h f d h hi h b

the sequence of data exchange, which can be described using a time event diagram.

(ii) th ifi ti f th f t f th d t

(ii) the specification of the format of the data exchanged at each step.

Distributed Computing, M. L. Liu

(31)

HTTP: A sample protocol

z The Hypertext Transfer Protocol is a protocol for a

process (the browser) to obtain a document from a web server process.

z It is a request/response protocol: a browser sends a

b hi h li i h

request to a web server process, which replies with a response.

Distributed Computing, M. L. Liu

(32)

The Basic HTTP protocol

web server web browser

request is a message in 3 parts: request request is a message in 3 parts:

- <command> <document adddress> <HTTP version> - an optional header

- optional data for CGI data using post method

response response is a message consisting of 3 parts:

- a status line of the format <protocol><status code><description> - header information, which may span several lines;, y p ;

- the document itself.

We will explore HTTP in details later this quarter.

Distributed Computing, M. L. Liu

(33)

A sample HTTP session

S i t t t d T O t 10 21 49 28 2000 Script started on Tue Oct 10 21:49:28 2000 9:49pm telnet www.csc.calpoly.edu 80 Trying 129.65.241.20...

Connected to tiedye2-srv.csc.calpoly.edu. Escape character is '^]'.

GET /~mliu/ HTTP/1 0 HTTP Request

GET / mliu/ HTTP/1.0 HTTP Request

HTTP/1.1 200 OK HTTP response status line

Date: Wed, 11 Oct 2000 04:51:18 GMT HTTP response header

Server: Apache/1.3.9 (Unix) ApacheJServ/1.0 Last-Modified: Tue, 10 Oct 2000 16:51:54 GMT Last Modified: Tue, 10 Oct 2000 16:51:54 GMT ETag: "1dd1e-e27-39e3492a"

Accept-Ranges: bytes Content-Length: 3623 Connection: close

Content-Type: text/html

<HTML> document content <HEAD>

<TITLE> Mei-Ling L. Liu's Home Page </TITLE>

/HEAD

Distributed Computing, M. L. Liu

33

</HEAD>

(34)

IPC paradigms and implementations

Paradigms of IPC of different levels of abstraction have evolved, with corresponding implementations.

remote procedure/method

socket API Unix socket API, Winsock

Remote Procedure Call (RPC), Java RMI

level of

abstraction IPC paradigms Example IPC Implementations

socket API

data transmission serial/parallel communication

,

Distributed Computing, M. L. Liu

(35)

Summary

Interprocess communications (IPC) is the backbone of distributed computing. In this chapter we have looked at the principles of IPC, including the followings:

at the principles of IPC, including the followings:

• What is interprocess communication? Unicast?

Multicast?

What is an IPC application programming interface

• What is an IPC application programming interface

(API) and what primitive operations does such an interface provide?

• Event synchronization: How do processes engaged

in IPC synchronize or coordinate the send and

receive operations? What role do blocking

Distributed Computing, M. L. Liu

35

(36)

Summary - 2

Data representation or encoding schemes: Why is

data marshalling necessary? What are the two components involved in data marshalling? What are the different levels of abstraction in data

encoding? What is meant b object seriali ation? encoding? What is meant by object serialization?

• What is the difference between

connection-oriented and connectionless interprocess oriented and connectionless interprocess

communications? Compare and contrast the two.

Distributed Computing, M. L. Liu

(37)

Summary - 3

• What is an event diagram? How can it be used to

describe the sequence of events and their

synchronization in a protocol such as the HTTP?

• What is a sequence diagram? How can it be used

d ib h f i l h

to describe the sequence of events in a protocol such as the HTTP?

Wh t th diff t l l f b t ti i IPC

• What are the different levels of abstraction in IPC

paradigms?

Distributed Computing, M. L. Liu

Referensi

Dokumen terkait

[r]

NILAI GOTONG ROYONG UNTUK MEMPERKUAT SOLIDARITAS DALAM KEHIDUPAN MASYARAKAT KAMPUNG NAGA.. Universitas Pendidikan Indonesia | repository.upi.edu

Bank Kustodian akan menerbitkan Surat Konfirmasi Transaksi Unit Penyertaan yang menyatakan antara lain jumlah investasi yang dialihkan dan dimiliki serta Nilai Aktiva

Puji dan syukur penulis panjatkan kepada Tuhan Yang Maha Kuasa atas berkat dan kasih karunia-Nya sehingga penulis dapat menyelesaikan skripsi yang berjudul “

[r]

Sex Education terhadap Kesehatan Reproduksi pada Remaja Putri usia 16 tahun-19 tahun di SMAN 3 Bangkalan adalah sebagai berikut : 1) Mayoritas 57 (85,1% ) remaja putri

UJI VALID ITAS D AN RELIABILITAS KONSTRUKSI ALAT UKUR POWER END URANCE TUNGKAI Universitas Pendidikan Indonesia | repository.upi.edu | perpustakaan.upi.edu..

Further, our results indicate a substitutive relation between the CFO’s and the CEO’s responsibility for reporting bias: Assigning higher responsibility to the CEO is more likely