Académique Documents
Professionnel Documents
Culture Documents
Interprocess Communications
-
Exchange of data between two or more separate, independent processes/threads. Operating systems provide facilities/resources for interprocess communications (IPC), such as message queues, semaphores, and shared memory. Distributed computing systems make use of these facilities/resources to provide application programming interface (API) which allows IPC to be programmed at a higher level of abstraction. (e.g., send and receive) Distributed computing requires information to be exchanged among independent processes.
...
m m
P4
P1
P1
unicast
4
multicast
Process 1 data
Process 2
sender
5
receiver
Receive ( [sender], message storage object) Connect (sender address, receiver address), for connection-oriented communication. Send ( [receiver], message) Disconnect (connection identifier), for connection-oriented communication.
ope rations: S1: acce pt conne ction S2: re ce ive (re que st) S3: se nd (re sponse ) S3: disconne ct s4 C 1: make conne ction C 2: se nd (re que st) C 3: re ce ive (re sponse ) C 4: disconne ct
Web browser
Event Synchronization
Interprocess communication may require that the two processes synchronize their operations: one side sends, then the other receives until all data has been sent and received. Ideally, the send operation starts before the receive operation commences. In practice, the synchronization requires system support.
8
Event Diagram
acknowledgement of data received provided by the IPC facility blocking receive ends
suspended period
Client Sender
Server Receiver
10
Event Diagram
blocking receive starts
nonblocking send operation execution flow suspended period blocking receive returns
Client Sender
Server Receiver
11
blocking send issued nonblocking receive issued execution flow suspended period
12
indefinite blocking
13
nonblocking receive issued and returned immediately blocking send issued transparent acknowledgement provided by the IPC facility process is notified of the arrival of data
14
Data from P1 arrived to P2 before P2 issues a non-blocking receive op. P2 is notified of the arrival of data
nonblocking receive issued and returned immediately blocking send issued process is notified of the arrival of data
15
Event diagram
Process B Process A time request 1
response 1
16
17
18
19
"receive from process 2" issued; process 1 blocked pending data from process 2.
an ope ration proce ss e xe cuting proce ss blocke d
"receive from process 1" issued; process 2 blocked pending data from process 1.
20
Data Representation
Data transmitted on the network is a binary stream. An interprocess communication system may provide the capability to allow data representation to be imposed on the raw data. Because different computers may have different internal storage format for the same data type, an external representation of data may be necessarystandard format. Data marshalling is the process of (I) flattening a data structure, and (ii) converting the data to an external representation. Some well known external data representation schemes are: Sun XDR (External Data Representation) ASN.1 (Abstract Syntax Notation One) XML (Extensible Markup Language)
21
data encoding schemes application specific data encoding language general data encoding language
22
XML has syntax analogous to HTML. HTML. means, Unlike HTML, XML tags tell you what the data means, rather than how to display it. Example:
<message>
<to>you@yourAddress.com</to> </to> <to> <from>me@myAddress.com</from> <from> </from> <subject>XML Is Really Cool</subject> <subject> </subject> <text> How many ways is XML cool? Let me count the ways... </text>
textXML is a text-based markup language that is fast becoming the standard for data interchange on the Web.
23
</message>
Data Marshalling
"This is a test." host A 1.2 7.3 -1.5 1. flattening of structured data items 2. converting data to external (network) representation
marshalling
1. convert data to internal representation 2. rebuild data structures. 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.
24
host B
presentation layer
presentation layer
session layer
Message
session layer
transport layer
transport layer
network layer
network layer
physical layer
physical layer
25
Text-based protocols
Data marshalling is at its simplest when the data characters, text. exchanged is a stream of characters, or text. 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 character-strings. responses in the form of character-strings. Such text-based. protocols are said to be text-based. Many popular network protocols, including FTP (File HTTP, Transfer Protocol), HTTP, and SMTP (Simple Mail text-based. Transfer Protocol), are text-based.
26
Event diagram
Process 2 Process 1 time request 1
response 1
27
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 is a message consisting of 3 parts: - a status line of the format <protocol><status code><description> - header information, which may span several lines; - the document itself.
response
28
Sequence Diagram
Process A Process B
request 1
response 1
29
request 1
response 1
30
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 format of the data exchange at each step.
31
32
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 is a message consisting of 3 parts: - a status line of the format <protocol><status code><description> - header information, which may span several lines; - the document itself. We will explore HTTP in details later this quarter.
response
33
Request HTTP R equest HTTP response status line HTTP response header
document content
34
HTTP Session
1. Telnet to your favorite Web server:
unix> telnet ise.gmu.edu 80 Opens a TCP connection to port 80 at ise.gmu.edu. (default HTTP server port)
Type above commands and hit carriage return twice, you send this minimal but complete GET request to HTTP server
35
level of abstraction
Example IPC Implementations Remote Procedure Call (RPC), Java RMI Unix socket API, Winsock serial/parallel communication
36