Browse over 20 million
homework answers & study documents

Inter Process Communications

Rating

Showing Page:
1/32
Interprocess Communication
5
CHAPTER 3,PROCESSES, DISCUSSED THE CREATION OF PROCESSES and showed
how one process can obtain the exit status of a child process.Thats the simplest form
of communication between two processes, but its by no means the most powerful.The
mechanisms of Chapter 3 dont provide any way for the parent to communicate with
the child except via command-line arguments and environment variables, nor any way
for the child to communicate with the parent except via the childs exit status. None
of these mechanisms provides any means for communicating with the child process
while it is actually running, nor do these mechanisms allow communication with a
process outside the parent-child relationship.
This chapter describes means for interprocess communication that circumvent these
limitations.We will present various ways for communicating between parents and chil-
dren, between unrelated processes, and even between processes on different
machines.
Interprocess communication (IPC) is the transfer of data among processes. For example,
a Web browser may request a Web page from a Web server, which then sends HTML
data.This transfer of data usually uses sockets in a telephone-like connection. In
another example, you may want to print the filenames in a directory using a command
such as
ls | lpr.The shell creates an ls process and a separate lpr process, connecting
06 0430 CH05 5/22/01 10:22 AM Page 95

Sign up to view the full document!

lock_open Sign Up
96
Chapter 5 Interprocess Communication
the two with a pipe, represented by the
| symbol. A pipe permits one-way commu-
nication between two related processes.The
ls process writes data into the pipe, and
the lpr process reads data from the pipe.
In this chapter, we discuss five types of interprocess communication:
n
Shared memory permits processes to communicate by simply reading and
writing to a specified memory location.
n
Mapped memory is similar to shared memory, except that it is associated with a
file in the filesystem.
n
Pipes permit sequential communication from one process to a related process.
n
FIFOs are similar to pipes, except that unrelated processes can communicate
because the pipe is given a name in the filesystem.
n
Sockets support communication between unrelated processes even on different
computers.
These types of IPC differ by the following criteria:
n
Whether they restrict communication to related processes (processes with a
common ancestor), to unrelated processes sharing the same filesystem, or to any
computer connected to a network
n
Whether a communicating process is limited to only write data or only
read data
n
The number of processes permitted to communicate
n
Whether the communicating processes are synchronized by the IPCfor
example, a reading process halts until data is available to read
In this chapter, we omit discussion of IPC permitting communication only a limited
number of times, such as communicating via a childs exit value.
5.1 Shared Memory
One of the simplest interprocess communication methods is using shared memory.
Shared memory allows two or more processes to access the same memory as if they all
called malloc and were returned pointers to the same actual memory.When one
process changes the memory, all the other processes see the modification.
5.1.1 Fast Local Communication
Shared memory is the fastest form of interprocess communication because all
processes share the same piece of memory.Access to this shared memory is as fast as
accessing a processs nonshared memory, and it does not require a system call or entry
to the kernel. It also avoids copying data unnecessarily.
06 0430 CH05 5/22/01 10:22 AM Page 96

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Unformatted Attachment Preview

06 0430 CH055/22/0110:22 AMPage 955Interprocess CommunicationCHAPTER 3, PROCESSES, DISCUSSED THE CREATION OF PROCESSES and showedhow one process can obtain the exit status of a child process.Thats the simplest formof communication between two processes, but its by no means the most powerful.Themechanisms of Chapter 3 dont provide any way for the parent to communicate withthe child except via command-line arguments and environment variables, nor any wayfor the child to communicate with the parent except via the childs exit status. Noneof these mechanisms provides any means for communicating with the child processwhile it is actually running, nor do these mechanisms allow communication with aprocess outside the parent-child relationship.This chapter describes means for interprocess communication that circumvent theselimitations.We will present various ways for communicating between parents and children, between unrelated processes, and even between processes on differentmachines.Interprocess communication (IPC) is the transfer of data among processes. For example,a Web browser may request a Web page from a Web server, which then sends HTMLdata.This transfer of data usually uses sockets in a telephone-like connection. Inanother example, you may want to print the filenames in a directory using a commandsuch as ls | lpr.The shell creates an ls process and a separate lpr process, connecting06 0430 CH05965/22/0110:22 AM ...
Purchase document to see full attachment

Anonymous
Return customer, been using sp for a good two years now.

Anonymous
Thanks as always for the good work!

Anonymous
Document I purchased was really helpful. Had answers to help me with my hmw.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4