File: 2.html

package info (click to toggle)
lg-issue91 1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,084 kB
  • ctags: 266
  • sloc: ansic: 1,343; perl: 104; sh: 98; makefile: 34
file content (219 lines) | stat: -rw-r--r-- 10,261 bytes parent folder | download
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
208
209
210
211
212
213
214
215
216
217
218
219
<!--startcut  ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<META NAME="generator" CONTENT="lgazmail v1.4G.h">
<TITLE>The Answer Gang 91: concurrent processes</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!--endcut  ==============================================-->
<!-- begin 2 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif" 
	height="50" width="60" alt="(?) " border="0"
	>concurrent processes</H3>


<p><strong>From socrates sid 
</strong></p> 
<p></strong></p>

<p align="right"><strong>Answered By  Jim Dennis
</strong></p>
<P><STRONG>
What are concurrent processes how they work in distributed and shared
systems?Can they be executed parallel or they just give the impression
of running parallel.
</STRONG></P>
<blockQuote>
<IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [JimD]
</blockQuote>
<blockQuote>
"concurrent processes" isn't a special term of art.  A process is a
program running on a UNIX/Linux system, created with <TT> fork()</TT> (a special
form of the <TT> clone()</TT> system call under Linux).  A process has it's own
(virtual) memory space.  Under Linux a different form of the <TT> clone()</TT>
system call creates a "thread" (specifically a kernel thread).  Kernel
threads have their own process ID (PIDs) but share their memory with
other threads in their process.
</blockQuote>
<blockQuote>
There are a number of technical differences between processes and
kernel threads under Linux (mostly having to do with signal
dispatching).  The gist of it is that a process is a memory space
<EM>and</EM> a scheduling and signal handling unit; while a kernel thread
is just a scheduling and signal handling unit. Processes also have
their own security credentials (UIDs, GIDs, etc) and file descriptors.
Kernel threads share common identity and file descriptor sets.
</blockQuote>
<blockQuote>
There are also "psuedo-threads" (pthreads) which are implemented within
a process via library support; psuedo-threads are not a kernel API,
and a kernel need not have any special support for them.  The main
differences betwen kernel threads and pthreads have to do with blocking
characteristics.  If a pthread makes a "blocking" form of a system call
(such as the <TT> read()</TT> or <TT> write()</TT>) then the whole process (all threads)
can be blocked.  Obviously the library should provide support to help
the programmer avoid doing these things; there used to be separate
thread aware (re-entrant) versions of the C libraries to link against
pthreads programs under Linux.  However, all recent versions of glibc
(the GNU C libraries used by all mainstream Linux systems)  are
re-entrant and have clearly defined thread-safe APIs.  (In some cases,
like <TT> strtok()</TT> there are special threading versions which must be used
explicitly --- due to some historical interactions between those
functions and certain global variables).
</blockQuote>
<blockQuote>
Kernel threads can make blocking system calls as appropriate to their
needs -- since other threads in that process group will still get
time slices scheduled to them independently.
</blockQuote>
<blockQuote>
Other parts of your question (which appears to be a lame "do my homework"
posting, BTW) are too vague and lack sufficient context to answer well.
</blockQuote>
<blockQuote>
For example: Linux is not a "distributed system."  You can build
distributed systems using Linux --- by providing some protocol over
any of the existing communications (networking and device interface)
mechanisms.  You could conceivably implement a distributed system
over a variety of different process, kernel thread, and pthread models
and over a variety of different networking protocols (mostly over
TCP/IP, and UDP, but also possible using direct, lower level, ethernet
frames; or by implementing custom protocols over any other device).
</blockQuote>

<blockQuote><ul>
<!-- *) (I've heard of a protocol that was done over PC parallel parts; -->

<LI>(I've heard of a protocol that was done over PC parallel parts;

<!--     limited bandwidth but very low latencies!  Reducing latency is often -->
    limited bandwidth but very low latencies!  Reducing latency is often

<!--     far more important in tightly coupled clusters than bandwidth). -->
    far more important in tightly coupled clusters than bandwidth).
</ul></blockQuote>
<blockQuote>
So, the question:
</blockQuote>

<blockquote><pre>What are concurrent processes how they work in distributed and shared
systems?
</pre></blockquote>
<blockQuote>
... doesn't make sense (even if we ignore the poor grammar). I also
don't know what a "shared system" is.  It is also not a term of art.
</blockQuote>
<blockQuote>
On SMP (symmetrical multiprocessor) systems the Linux kernel
initializes all available CPUs (processors) and basically let's them
compete to run processes.  Each CPU, at each 10ms context switch
time scans the run list (the list of processes and kernel threads
which are ready to run --- i.e. not blocked on I/O and not waiting
or sleeping) and grabs a lock on it, and runs it for awhile.  It's
actually considerably more complicated than that --- since there are
features that try to implement "processor affinity" (to insure that
processes will tend to run on the same CPU from one context switch to
another --- to take advantage of any L1 cache lines that weren't
invalidated by the intervening processes/threads) and many other
details.
</blockQuote>
<blockQuote>
However, the gist of this MP model is that processes and kernel
thread <EM>may</EM> be executing in parallel.  The context switching
provides the "impression" (multi-tasking) that many processes are
running "simultaneously" by letting each to a little work, so in
aggregate they've all done some things (responded) on any human
perceptible time scale.
</blockQuote>
<blockQuote>
Obviously a "distributed" system has multiple processors (in separate
systems) and thus runs processes on each of those "nodes" -- which
is truly parallel.  An SMP machine is a little like a distributed
system (cluster of machines) except that all of the CPUs share the same
memory and other devices.  A NUMA (non-uniform memory access) system is
a form of MP (multi-processing) where the CPUs share the same memory ---
but some of the RAM (memory) is "closer" to some CPUs than to others (in
terms of latency and access characteristics.  In other words the memory
isn't quite as "symmetrical."  (However, an "asymmetric MP" system
would be one where there are multiple CPUs that have different
functions --- some some CPUs were dedicated to some sorts of tasks
while other CPUs performs other operations.  In many ways a modern
PC with a high end video card is an example of an asymmetrical MP
system.  A modern "GPU" (graphical processing unit) has quite a bit
of memory and considerable processor power of its own; and the video
drivers provide ways for the host system to offload quite a bit of
work (texturing, polygon shifting, scaling, shading, rotations, etc)
unto the video card.  (To a more subtle degree the hard drives, sound
cards, ethernet and some SCSI, RAID, and firewired adapters, in a modern
PC are other examples of asymmetric multi-processing since many of
these have CPUs, memory and programs (often in firmware, but sometimes
overridden by the host system.  However, that point is moot and I might
have to debate someone at length to arrive at a satisfactory
distinction between "intelligent peripherals" and asymmetric
MP.  In general the phrase "asymmetric multi-processing" is simply not
used in modern computing; so the "S" in "SMP" seems to be redundant).
</blockQuote>

<!-- end 2 -->
<!-- *** BEGIN copyright *** -->
<hr>
<CENTER><SMALL><STRONG>
<h5>
<br>Copyright &copy; 2003
<br>Copying license <A HREF="">http://www.linuxgazette.com/copying.html</A>
<BR>Published in Issue 91 of <i>Linux Gazette</i>, June 2003</H5>
</STRONG></SMALL></CENTER>
<!-- *** END copyright *** -->

<SMALL><CENTER><H6 ALIGN="center">HTML script maintained by
        <A HREF="mailto:star@starshine.org">Heather Stern</a> of
        Starshine Technical Services,
       <A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6></SMALL></CENTER>
<HR>

<!--startcut ======================================================= -->
<P> <hr> 
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
	><IMG ALT="" SRC="../../gx/navbar/left.jpg"
        WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0"
><A HREF="../index.html"
	><IMG SRC="../../gx/navbar/toc.jpg" align="middle"
              ALT="[ Table Of Contents ]" border="0"></A
><A HREF="../lg_answer.html"
	><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
              ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer.html#greeting"><img align="middle"
	src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
  <A HREF="../../tag/bios.html">Meet&nbsp;the&nbsp;Gang</A> &nbsp;
  <A HREF="1.html">1</A> &nbsp;
  <A HREF="2.html">2</A> &nbsp;
  <A HREF="3.html">3</A> &nbsp;
  <A HREF="4.html">4</A> 
  </td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
	><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
              ALT="[ Index of Past Answers ]" border="0"></A
><IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
        WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<!--endcut ========================================================= -->
<P> <hr> 
<!--startcut ======================================================= -->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!--endcut ========================================================= -->
<!--startcut ======================================================= -->
</BODY></HTML>
<!--endcut ========================================================= -->