Information Technology Reference
In-Depth Information
3.4
Case Study: Interprocess communication
For many of the same reasons it makes sense to construct complex applications
from simpler modules, it often makes sense to create applications that can spe-
cialize on a specific task, and then combine those applications into more complex
structures. We gave an example above with the C compiler, but many parts
of the operating system are structured this way. For example, instead of every
program needing to know how to coordinate access to a printer, UNIX has a
printer server, a specialized program for managing the printer queue.
For this to work, we need a way for processes to communicate with each
other. Three widely used forms of interprocess communication are:
Producer-consumer. In this model, programs are structured to accept
as input the output of other programs. Communication is one-way: the
producer only writes, and the consumer only reads. As we explained
above, this allows chaining: a consumer can be in turn a producer for a
different process. Much of the success of UNIX was due to its ability to
easily compose many different programs together in this fashion.
Client-server. An alternative model is to allow two-way communication
between processes, as in client-server computing. The server implements
some specialized task, such as managing the printer queue or managing
the display. Clients send requests to the server to do some task, and when
the operation is complete, the server replies back to the client.
File system. Another way programs can be connected together is through
reading and writing files. A text editor can import an image created by a
drawing program, and the editor can in turn write an HTML file that a
web server can read to know how to display a web page. A key distinc-
tion is that, unlike the first two modes, communication through the file
system can be separated in time: the writer of the file does not need to
be running at the same time as the file reader. Therefore data needs to
be stored persistently on disk or other stable storage, and the data needs
to be named so that you can find the file when needed later on.
All three models are widely used both on a single system and over a network.
For example, the Google mapreduce utility is a central part of many of Google's
services, and it operates over a network in a producer-consumer fashion: the
output of the map function is sent to the machines running the reduce function.
The web is an example of client-server computing, and many enterprises and
universities run centralized file servers to connect a text editor on one computer
with a compiler running on another.
As persistent storage, file naming, and distributed computing are each com-
plex topics in their own right, we defer the discussions of those topics to later
chapters. Here we focus on interprocess communication, where both processes
are running simultaneously on the same machine.
Search WWH ::




Custom Search