File: ipc.html

package info (click to toggle)
lg-issue23 4-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,360 kB
  • ctags: 430
  • sloc: makefile: 36; sh: 4
file content (207 lines) | stat: -rw-r--r-- 8,556 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Generator" CONTENT="Microsoft Word 97">
   <META NAME="Template" CONTENT="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01b6C [en] (X11; I; Linux 2.1.47 i486) [Netscape]">
   <TITLE>Processes and Process Context</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">

<DIV ALIGN=right>&nbsp;</DIV>
<FONT COLOR="#3366FF"><FONT SIZE=+3><B>Communication Between Processes</B></FONT></FONT><FONT COLOR="#3366FF"><FONT SIZE=+3></FONT></FONT>

<P><FONT SIZE=+1>&nbsp;Processes operate within their own virtual address
space and are protected by the operating system from interference by other
processes. By default a user process cannot communicate with another process
unless it makes use of secure, kernel managed mechanisms. There are many
times when processes will need to share common resources or synchronise
their actions. One possibility is to use threads, which by definition can
share memory within a process. This option is not always possible (or wise)
due to the many disadvantages which can be experienced with threads. Methods
of passing messages or data between processes are therefore required.</FONT>

<P><FONT SIZE=+1>&nbsp;<B><FONT COLOR="#FF0000">Linux</FONT></B> supports
the following methods of communication. System V IPC refers to the version
of Unix in which the concepts noted below were first introduced.</FONT>
<BR>&nbsp;
<TABLE BORDER CELLPADDING=7 WIDTH="510" BORDERCOLOR="#000000" >
<TR>
<TD VALIGN=TOP WIDTH="20%">
<DIR><FONT SIZE=+1>Signals</FONT></DIR>
</TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Signals are used to signal asynchronous
events between processes. A process may implement a signal handler to carry
out required when an event occurs or may use the system default actions.
Most signals can be ignored or blocked, though the KILL signal cannot be
ignored and will result in a non clean process exit.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%">
<DIR><FONT FACE="Courier New"><FONT SIZE=+1>UNIX pipes</FONT></FONT></DIR>
</TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>A pipe connects the standard output
of one process to the standard input of another. They provide a method
of one-way communication between processes in a parent-child relationship
and for this reason may be called half duplex pipes.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Named Pipes (FIFOs)</FONT>&nbsp;

<P><FONT SIZE=+1>&nbsp;</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Named pipes appear similar to
regular pipes but are implemented as device special First In-First Out
(FIFO) files in the file system. It is not necessary for processes to maintain
a parent-child relationship for them to communicate via named pipes. Named
pipes are persistent and may be reused after their initial setup.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>System V IPC Message Queues</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Message queues consist of a linked
list within the kernel's addressing space. Messages are added to the queue
sequentially and may be retrieved from the queue in several different ways.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>System V IPC Semaphores</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Semaphores are counters used to
control access to shared resources by multiple processes. They are most
often used as a locking mechanism to prevent processes from accessing a
particular resource while another process is performing operations on it.
Semaphores are implemented as sets, though a set may have a single member.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>System V IPC Shared Memory</FONT>&nbsp;

<P><FONT SIZE=+1>&nbsp;</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Shared memory is a mapping of
an area of memory into the address space of more than one process. This
is the fastest form of IPC as processes do not subsequently need access
to kernel services in order to share data.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Full-duplex pipes (STREAMS)</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>STREAMS were introduced by AT&amp;T
and are used for character based I/O within the kernel and between it?s
associated device drivers as a full duplex transfer path between processes.
Internally pipes may be implemented as STREAMS.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Remote Procedure Call (RPC)</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>A network inter-process connection
protocol based on Sun Microsystems' RPC standard.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Networking sockets (Berkeley style)</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Sockets allow local or network
connection between processes. Socket names are implemented within a domain.
In the UNIX domain a socket is given a path name within the file system.
Other processes may use that name to communicate.</FONT></TD>
</TR>
</TABLE>
<FONT SIZE=+1>&nbsp;</FONT>
<BR><FONT SIZE=+1><B><FONT COLOR="#FF0000">Windows NT</FONT></B> inter-process
communication and synchronisation facilities include the following :</FONT>
<BR>&nbsp;
<TABLE BORDER CELLPADDING=7 WIDTH="510" BORDERCOLOR="#000000" >
<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Events or Event Pairs</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Event handles may be inherited,
passed on creation or duplicated for a process. Event handles may optionally
have names and are signalled using the SetEvent call.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT FACE="Courier New"><FONT SIZE=+1>Anonymous
Pipes</FONT></FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Used primarily for communication
between related processes. Anonymous pipes cannot be used over a network.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT FACE="Courier New"><FONT SIZE=+1>Named
Pipes (FIFOs)</FONT></FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Named pipes are similar to anonymous
pipes but may be referenced by name rather than handle, may be used over
a network and can use asynchronous, overlapped I/O.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Semaphores</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>Like Linux, Windows NT semaphore
objects are implemented as counters which act as guardians over a section
of code or resource.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Shared Memory</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>A <I>section </I>object is a Win32
subsystem object which is made available as a<I> file mapping object </I>which
two or more processes may share. One thread creates the section object
and other threads obtain handles to it.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Remote Procedure Calls (RPCs)</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>An implementation of the Distributed
Computing Environment (DCE) standard for calling processes over a network.</FONT></TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT SIZE=+1>Local Procedure Calls (LPCs)</FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>A facility similar in usage to
RPC but in fact being a cut down version that can act only on a local computer
to perform efficient message passing between client/server processes using
kernel provided mechanisms. There are three basic choices :</FONT>&nbsp;
<OL TYPE="i">
<LI>
<FONT SIZE=+1>Messages may be passed into a server port objects message
queue - used for small messages.</FONT></LI>

<LI>
<FONT SIZE=+1>Messages are passed via a shared memory object.</FONT></LI>

<LI>
<FONT SIZE=+1>Quick LPC is used by portions of the Win32 subsystem to achieve
minimum overhead and maximum speed.</FONT></LI>
</OL>
</TD>
</TR>

<TR>
<TD VALIGN=TOP WIDTH="20%"><FONT FACE="Courier New"><FONT SIZE=+1>STREAMS</FONT></FONT></TD>

<TD VALIGN=TOP WIDTH="80%"><FONT SIZE=+1>An implementation of the Unix
System V driver environment used in networking.</FONT></TD>
</TR>
</TABLE>
&nbsp;

<P>&nbsp;
<DIV ALIGN=right><FONT SIZE=-1>&nbsp;</FONT><A HREF="timers.html"><IMG SRC="../gx/flower/cyan_lef.gif" BORDER=0 HEIGHT=31 WIDTH=31></A><A HREF="page1.html"><IMG SRC="../gx/flower/cyan_up.gif" BORDER=0 HEIGHT=31 WIDTH=31></A><A HREF="linuxproc.html"><IMG SRC="../gx/flower/cyan_rig.gif" BORDER=0 HEIGHT=31 WIDTH=31></A></DIV>

</BODY>
</HTML>