Chapter 2
Chapter 2
Chapter 2
Chapter 2
Interprocess Communications
Presentation Suggestions
This chapter is the foundation for distributed computing. For students who have never
been exposed to programming involving more than one process, this chapter can be
challenging.
Use inter-human communication as an analogy (see exercise 1) to get the students
motivated: they must appreciate the need for the primitive operations (send, receive),
for event synchronization, data representation and encoding, and protocols.
Explain that in interprocess communications, “synchronous” means “blocking” while
“asynchronous” means no blocking
The idea of blocking is not intuitive to most beginning students: again, use inter-person
communication as an analogy in your explanation for the need of blocking. Tell them
that they will see blocking in the concrete in Chapter 4, when the socket APIs are
introduced.
Be sure to clarify the difference between the time-event diagram (which shows
blocking) and the sequence diagram (which does not show blocking).
The demo illustrated in Figure 2.18 is is very effective for allowing the students to see
the actual exchange of data between two independent processes. During the demo, you
may want point out where blocking occurs, and point out clearly the source of the data
being displayed on screen.
Be sure to make clear to students that using telnet to interact with a text-based server is
not the normal way to conduct a protocol session. For interactive learning, it is a good
idea to go over the first six exercises in class during your presentation. For example,
invite the class to solve problem 1 after you have presented the idea of interprocess
communications; problem 2 after you introduced the terms synchronous and
asynchronous; and so forth.
Do encourage your students to look up the Internet Request for Comments (RFC) (see
the references): they may not understand the writing, but it’s a good idea to get them to
start thinking about specifying protocols and why protocols are needed.
The data requested by the receive operation has already arrived, the data is
delivered to process B and an acknowledgement from host 2’s IPC facility
will unblock process A subsequently.
b. Process B issues its receive operation prior to process A issues its send operation.
Answer:
There are two possible scenarios:
(i) 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 2’s IPC facility.
(ii) 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.
3. Repeat the last question. This time both operations (send, receive) are blocking.
Answer:
a. Process A issues its send operation prior to process B issues its receive
operation
b. Process B issues its receive operation prior to process A issues its send
operation.
a. Draw a time event diagram each to show the sequence of events and the
blocking and unblocking of each process:
ii. Suppose the same date has to be communicated to Process C, which uses a date
format of <year>-<month>-<date>(for example; 2001-01-31).
i. How can A send the date to B so that A does not have to do any
conversion?
Answer: A sends the date in American format. B will have to
convert the date to its local format upon receiving the date.
ii. How can A send the date to both B and C so that A does not have to
do any conversion?
9. Use telnet to interact with a daytime4 server process on a machine that you have access
to. Daytime server processes reside on port 13 of an IP host. (From a console screen
on a UNIX or Windows system, enter:
telnet<space> <domain name or IP address of the machine><space>13
Answer:
A sample session is shown below --
9:20pm falcon ~>telnet polylog1 13
Trying 129.65.60.104...
Connected to polylog1.cpunix.calpoly.edu.
Escape character is '^]'.
Fri Oct 12 21:21:21 2001
Connection closed by foreign host.
S: MAIL FROM:<mo@LBL-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<Jones@USC-ISI.ARPA>
R: OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISI.ARPA Service closing transmission channel
a. Use a sequence diagram to describe the interactions among the participating processes.
Answer:
d. Use telnet to connect to a system on which you have an SMTP email account, then send
yourself an email.
Log onto the system and check that the email indeed arrived.
Answer:
It can be done. However, please do not entertain the idea of using this technique
to forge email - many mail servers will track the originating IP address of the
client host and unauthorized email can be traced.