Ticket #13420: Symmetric Multiprocessing on Haiku .htm

File Symmetric Multiprocessing on Haiku .htm, 126.8 KB (added by andrewz, 8 years ago)

Symmetric Multiprocessing on Haiku

Line 
1<html xmlns:v="urn:schemas-microsoft-com:vml"
2xmlns:o="urn:schemas-microsoft-com:office:office"
3xmlns:w="urn:schemas-microsoft-com:office:word"
4xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
5xmlns="http://www.w3.org/TR/REC-html40">
6
7<head>
8<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
9<meta name=ProgId content=Word.Document>
10<meta name=Generator content="Microsoft Word 12">
11<meta name=Originator content="Microsoft Word 12">
12<link rel=File-List
13href="Symmetric%20Multiprocessing%20on%20Haiku%20_files/filelist.xml">
14<link rel=Edit-Time-Data
15href="Symmetric%20Multiprocessing%20on%20Haiku%20_files/editdata.mso">
16<!--[if !mso]>
17<style>
18v\:* {behavior:url(#default#VML);}
19o\:* {behavior:url(#default#VML);}
20w\:* {behavior:url(#default#VML);}
21.shape {behavior:url(#default#VML);}
22</style>
23<![endif]--><!--[if gte mso 9]><xml>
24 <o:DocumentProperties>
25 <o:Author>Andrew</o:Author>
26 <o:LastAuthor>Andrew</o:LastAuthor>
27 <o:Revision>3</o:Revision>
28 <o:TotalTime>489</o:TotalTime>
29 <o:Created>2017-04-08T13:41:00Z</o:Created>
30 <o:LastSaved>2017-04-08T13:45:00Z</o:LastSaved>
31 <o:Pages>5</o:Pages>
32 <o:Words>2204</o:Words>
33 <o:Characters>12568</o:Characters>
34 <o:Lines>104</o:Lines>
35 <o:Paragraphs>29</o:Paragraphs>
36 <o:CharactersWithSpaces>14743</o:CharactersWithSpaces>
37 <o:Version>12.00</o:Version>
38 </o:DocumentProperties>
39</xml><![endif]-->
40<link rel=dataStoreItem
41href="Symmetric%20Multiprocessing%20on%20Haiku%20_files/item0010.xml"
42target="Symmetric%20Multiprocessing%20on%20Haiku%20_files/props0011.xml">
43<link rel=themeData
44href="Symmetric%20Multiprocessing%20on%20Haiku%20_files/themedata.thmx">
45<link rel=colorSchemeMapping
46href="Symmetric%20Multiprocessing%20on%20Haiku%20_files/colorschememapping.xml">
47<!--[if gte mso 9]><xml>
48 <w:WordDocument>
49 <w:SpellingState>Clean</w:SpellingState>
50 <w:GrammarState>Clean</w:GrammarState>
51 <w:TrackMoves>false</w:TrackMoves>
52 <w:TrackFormatting/>
53 <w:PunctuationKerning/>
54 <w:ValidateAgainstSchemas/>
55 <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
56 <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
57 <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
58 <w:DoNotPromoteQF/>
59 <w:LidThemeOther>EN-US</w:LidThemeOther>
60 <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
61 <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
62 <w:Compatibility>
63 <w:BreakWrappedTables/>
64 <w:SnapToGridInCell/>
65 <w:WrapTextWithPunct/>
66 <w:UseAsianBreakRules/>
67 <w:DontGrowAutofit/>
68 <w:SplitPgBreakAndParaMark/>
69 <w:DontVertAlignCellWithSp/>
70 <w:DontBreakConstrainedForcedTables/>
71 <w:DontVertAlignInTxbx/>
72 <w:Word11KerningPairs/>
73 <w:CachedColBalance/>
74 </w:Compatibility>
75 <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
76 <m:mathPr>
77 <m:mathFont m:val="Cambria Math"/>
78 <m:brkBin m:val="before"/>
79 <m:brkBinSub m:val="&#45;-"/>
80 <m:smallFrac m:val="off"/>
81 <m:dispDef/>
82 <m:lMargin m:val="0"/>
83 <m:rMargin m:val="0"/>
84 <m:defJc m:val="centerGroup"/>
85 <m:wrapIndent m:val="1440"/>
86 <m:intLim m:val="subSup"/>
87 <m:naryLim m:val="undOvr"/>
88 </m:mathPr></w:WordDocument>
89</xml><![endif]--><!--[if gte mso 9]><xml>
90 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
91 DefSemiHidden="true" DefQFormat="false" DefPriority="99"
92 LatentStyleCount="267">
93 <w:LsdException Locked="false" Priority="0" SemiHidden="false"
94 UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
95 <w:LsdException Locked="false" Priority="9" SemiHidden="false"
96 UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
97 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
98 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
99 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
100 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
101 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
102 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
103 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
104 <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
105 <w:LsdException Locked="false" Priority="39" Name="toc 1"/>
106 <w:LsdException Locked="false" Priority="39" Name="toc 2"/>
107 <w:LsdException Locked="false" Priority="39" Name="toc 3"/>
108 <w:LsdException Locked="false" Priority="39" Name="toc 4"/>
109 <w:LsdException Locked="false" Priority="39" Name="toc 5"/>
110 <w:LsdException Locked="false" Priority="39" Name="toc 6"/>
111 <w:LsdException Locked="false" Priority="39" Name="toc 7"/>
112 <w:LsdException Locked="false" Priority="39" Name="toc 8"/>
113 <w:LsdException Locked="false" Priority="39" Name="toc 9"/>
114 <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
115 <w:LsdException Locked="false" Priority="10" SemiHidden="false"
116 UnhideWhenUsed="false" QFormat="true" Name="Title"/>
117 <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
118 <w:LsdException Locked="false" Priority="11" SemiHidden="false"
119 UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
120 <w:LsdException Locked="false" Priority="22" SemiHidden="false"
121 UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
122 <w:LsdException Locked="false" Priority="20" SemiHidden="false"
123 UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
124 <w:LsdException Locked="false" Priority="59" SemiHidden="false"
125 UnhideWhenUsed="false" Name="Table Grid"/>
126 <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
127 <w:LsdException Locked="false" Priority="1" SemiHidden="false"
128 UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
129 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
130 UnhideWhenUsed="false" Name="Light Shading"/>
131 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
132 UnhideWhenUsed="false" Name="Light List"/>
133 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
134 UnhideWhenUsed="false" Name="Light Grid"/>
135 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
136 UnhideWhenUsed="false" Name="Medium Shading 1"/>
137 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
138 UnhideWhenUsed="false" Name="Medium Shading 2"/>
139 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
140 UnhideWhenUsed="false" Name="Medium List 1"/>
141 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
142 UnhideWhenUsed="false" Name="Medium List 2"/>
143 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
144 UnhideWhenUsed="false" Name="Medium Grid 1"/>
145 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
146 UnhideWhenUsed="false" Name="Medium Grid 2"/>
147 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
148 UnhideWhenUsed="false" Name="Medium Grid 3"/>
149 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
150 UnhideWhenUsed="false" Name="Dark List"/>
151 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
152 UnhideWhenUsed="false" Name="Colorful Shading"/>
153 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
154 UnhideWhenUsed="false" Name="Colorful List"/>
155 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
156 UnhideWhenUsed="false" Name="Colorful Grid"/>
157 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
158 UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
159 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
160 UnhideWhenUsed="false" Name="Light List Accent 1"/>
161 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
162 UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
163 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
164 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
165 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
166 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
167 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
168 UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
169 <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
170 <w:LsdException Locked="false" Priority="34" SemiHidden="false"
171 UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
172 <w:LsdException Locked="false" Priority="29" SemiHidden="false"
173 UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
174 <w:LsdException Locked="false" Priority="30" SemiHidden="false"
175 UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
176 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
177 UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
178 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
179 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
180 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
181 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
182 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
183 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
184 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
185 UnhideWhenUsed="false" Name="Dark List Accent 1"/>
186 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
187 UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
188 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
189 UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
190 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
191 UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
192 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
193 UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
194 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
195 UnhideWhenUsed="false" Name="Light List Accent 2"/>
196 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
197 UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
198 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
199 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
200 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
201 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
202 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
203 UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
204 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
205 UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
206 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
207 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
208 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
209 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
210 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
211 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
212 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
213 UnhideWhenUsed="false" Name="Dark List Accent 2"/>
214 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
215 UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
216 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
217 UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
218 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
219 UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
220 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
221 UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
222 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
223 UnhideWhenUsed="false" Name="Light List Accent 3"/>
224 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
225 UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
226 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
227 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
228 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
229 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
230 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
231 UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
232 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
233 UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
234 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
235 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
236 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
237 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
238 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
239 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
240 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
241 UnhideWhenUsed="false" Name="Dark List Accent 3"/>
242 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
243 UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
244 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
245 UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
246 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
247 UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
248 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
249 UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
250 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
251 UnhideWhenUsed="false" Name="Light List Accent 4"/>
252 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
253 UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
254 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
255 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
256 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
257 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
258 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
259 UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
260 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
261 UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
262 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
263 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
264 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
265 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
266 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
267 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
268 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
269 UnhideWhenUsed="false" Name="Dark List Accent 4"/>
270 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
271 UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
272 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
273 UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
274 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
275 UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
276 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
277 UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
278 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
279 UnhideWhenUsed="false" Name="Light List Accent 5"/>
280 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
281 UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
282 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
283 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
284 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
285 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
286 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
287 UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
288 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
289 UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
290 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
291 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
292 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
293 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
294 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
295 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
296 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
297 UnhideWhenUsed="false" Name="Dark List Accent 5"/>
298 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
299 UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
300 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
301 UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
302 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
303 UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
304 <w:LsdException Locked="false" Priority="60" SemiHidden="false"
305 UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
306 <w:LsdException Locked="false" Priority="61" SemiHidden="false"
307 UnhideWhenUsed="false" Name="Light List Accent 6"/>
308 <w:LsdException Locked="false" Priority="62" SemiHidden="false"
309 UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
310 <w:LsdException Locked="false" Priority="63" SemiHidden="false"
311 UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
312 <w:LsdException Locked="false" Priority="64" SemiHidden="false"
313 UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
314 <w:LsdException Locked="false" Priority="65" SemiHidden="false"
315 UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
316 <w:LsdException Locked="false" Priority="66" SemiHidden="false"
317 UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
318 <w:LsdException Locked="false" Priority="67" SemiHidden="false"
319 UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
320 <w:LsdException Locked="false" Priority="68" SemiHidden="false"
321 UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
322 <w:LsdException Locked="false" Priority="69" SemiHidden="false"
323 UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
324 <w:LsdException Locked="false" Priority="70" SemiHidden="false"
325 UnhideWhenUsed="false" Name="Dark List Accent 6"/>
326 <w:LsdException Locked="false" Priority="71" SemiHidden="false"
327 UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
328 <w:LsdException Locked="false" Priority="72" SemiHidden="false"
329 UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
330 <w:LsdException Locked="false" Priority="73" SemiHidden="false"
331 UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
332 <w:LsdException Locked="false" Priority="19" SemiHidden="false"
333 UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
334 <w:LsdException Locked="false" Priority="21" SemiHidden="false"
335 UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
336 <w:LsdException Locked="false" Priority="31" SemiHidden="false"
337 UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
338 <w:LsdException Locked="false" Priority="32" SemiHidden="false"
339 UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
340 <w:LsdException Locked="false" Priority="33" SemiHidden="false"
341 UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
342 <w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
343 <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
344 </w:LatentStyles>
345</xml><![endif]-->
346<style>
347<!--
348 /* Font Definitions */
349 @font-face
350 {font-family:"Cambria Math";
351 panose-1:2 4 5 3 5 4 6 3 2 4;
352 mso-font-charset:0;
353 mso-generic-font-family:roman;
354 mso-font-pitch:variable;
355 mso-font-signature:-536870145 1107305727 0 0 415 0;}
356@font-face
357 {font-family:Cambria;
358 panose-1:2 4 5 3 5 4 6 3 2 4;
359 mso-font-charset:0;
360 mso-generic-font-family:roman;
361 mso-font-pitch:variable;
362 mso-font-signature:-536870145 1073743103 0 0 415 0;}
363@font-face
364 {font-family:Calibri;
365 panose-1:2 15 5 2 2 2 4 3 2 4;
366 mso-font-charset:0;
367 mso-generic-font-family:swiss;
368 mso-font-pitch:variable;
369 mso-font-signature:-536859905 -1073732485 9 0 511 0;}
370@font-face
371 {font-family:Tahoma;
372 panose-1:2 11 6 4 3 5 4 4 2 4;
373 mso-font-charset:0;
374 mso-generic-font-family:swiss;
375 mso-font-pitch:variable;
376 mso-font-signature:-520081665 -1073717157 41 0 66047 0;}
377 /* Style Definitions */
378 p.MsoNormal, li.MsoNormal, div.MsoNormal
379 {mso-style-unhide:no;
380 mso-style-qformat:yes;
381 mso-style-parent:"";
382 margin-top:0in;
383 margin-right:0in;
384 margin-bottom:10.0pt;
385 margin-left:0in;
386 line-height:115%;
387 mso-pagination:widow-orphan;
388 font-size:11.0pt;
389 font-family:"Calibri","sans-serif";
390 mso-ascii-font-family:Calibri;
391 mso-ascii-theme-font:minor-latin;
392 mso-fareast-font-family:Calibri;
393 mso-fareast-theme-font:minor-latin;
394 mso-hansi-font-family:Calibri;
395 mso-hansi-theme-font:minor-latin;
396 mso-bidi-font-family:"Times New Roman";
397 mso-bidi-theme-font:minor-bidi;}
398h1
399 {mso-style-priority:9;
400 mso-style-unhide:no;
401 mso-style-qformat:yes;
402 mso-style-link:"Heading 1 Char";
403 mso-style-next:Normal;
404 margin-top:24.0pt;
405 margin-right:0in;
406 margin-bottom:0in;
407 margin-left:0in;
408 margin-bottom:.0001pt;
409 line-height:115%;
410 mso-pagination:widow-orphan lines-together;
411 page-break-after:avoid;
412 mso-outline-level:1;
413 font-size:14.0pt;
414 font-family:"Cambria","serif";
415 mso-ascii-font-family:Cambria;
416 mso-ascii-theme-font:major-latin;
417 mso-fareast-font-family:"Times New Roman";
418 mso-fareast-theme-font:major-fareast;
419 mso-hansi-font-family:Cambria;
420 mso-hansi-theme-font:major-latin;
421 mso-bidi-font-family:"Times New Roman";
422 mso-bidi-theme-font:major-bidi;
423 color:#365F91;
424 mso-themecolor:accent1;
425 mso-themeshade:191;
426 mso-font-kerning:0pt;}
427p.MsoTitle, li.MsoTitle, div.MsoTitle
428 {mso-style-priority:10;
429 mso-style-unhide:no;
430 mso-style-qformat:yes;
431 mso-style-link:"Title Char";
432 mso-style-next:Normal;
433 margin-top:0in;
434 margin-right:0in;
435 margin-bottom:15.0pt;
436 margin-left:0in;
437 mso-add-space:auto;
438 mso-pagination:widow-orphan;
439 border:none;
440 mso-border-bottom-alt:solid #4F81BD 1.0pt;
441 mso-border-bottom-themecolor:accent1;
442 padding:0in;
443 mso-padding-alt:0in 0in 4.0pt 0in;
444 font-size:26.0pt;
445 font-family:"Cambria","serif";
446 mso-ascii-font-family:Cambria;
447 mso-ascii-theme-font:major-latin;
448 mso-fareast-font-family:"Times New Roman";
449 mso-fareast-theme-font:major-fareast;
450 mso-hansi-font-family:Cambria;
451 mso-hansi-theme-font:major-latin;
452 mso-bidi-font-family:"Times New Roman";
453 mso-bidi-theme-font:major-bidi;
454 color:#17365D;
455 mso-themecolor:text2;
456 mso-themeshade:191;
457 letter-spacing:.25pt;
458 mso-font-kerning:14.0pt;}
459p.MsoTitleCxSpFirst, li.MsoTitleCxSpFirst, div.MsoTitleCxSpFirst
460 {mso-style-priority:10;
461 mso-style-unhide:no;
462 mso-style-qformat:yes;
463 mso-style-link:"Title Char";
464 mso-style-next:Normal;
465 mso-style-type:export-only;
466 margin:0in;
467 margin-bottom:.0001pt;
468 mso-add-space:auto;
469 mso-pagination:widow-orphan;
470 border:none;
471 mso-border-bottom-alt:solid #4F81BD 1.0pt;
472 mso-border-bottom-themecolor:accent1;
473 padding:0in;
474 mso-padding-alt:0in 0in 4.0pt 0in;
475 font-size:26.0pt;
476 font-family:"Cambria","serif";
477 mso-ascii-font-family:Cambria;
478 mso-ascii-theme-font:major-latin;
479 mso-fareast-font-family:"Times New Roman";
480 mso-fareast-theme-font:major-fareast;
481 mso-hansi-font-family:Cambria;
482 mso-hansi-theme-font:major-latin;
483 mso-bidi-font-family:"Times New Roman";
484 mso-bidi-theme-font:major-bidi;
485 color:#17365D;
486 mso-themecolor:text2;
487 mso-themeshade:191;
488 letter-spacing:.25pt;
489 mso-font-kerning:14.0pt;}
490p.MsoTitleCxSpMiddle, li.MsoTitleCxSpMiddle, div.MsoTitleCxSpMiddle
491 {mso-style-priority:10;
492 mso-style-unhide:no;
493 mso-style-qformat:yes;
494 mso-style-link:"Title Char";
495 mso-style-next:Normal;
496 mso-style-type:export-only;
497 margin:0in;
498 margin-bottom:.0001pt;
499 mso-add-space:auto;
500 mso-pagination:widow-orphan;
501 border:none;
502 mso-border-bottom-alt:solid #4F81BD 1.0pt;
503 mso-border-bottom-themecolor:accent1;
504 padding:0in;
505 mso-padding-alt:0in 0in 4.0pt 0in;
506 font-size:26.0pt;
507 font-family:"Cambria","serif";
508 mso-ascii-font-family:Cambria;
509 mso-ascii-theme-font:major-latin;
510 mso-fareast-font-family:"Times New Roman";
511 mso-fareast-theme-font:major-fareast;
512 mso-hansi-font-family:Cambria;
513 mso-hansi-theme-font:major-latin;
514 mso-bidi-font-family:"Times New Roman";
515 mso-bidi-theme-font:major-bidi;
516 color:#17365D;
517 mso-themecolor:text2;
518 mso-themeshade:191;
519 letter-spacing:.25pt;
520 mso-font-kerning:14.0pt;}
521p.MsoTitleCxSpLast, li.MsoTitleCxSpLast, div.MsoTitleCxSpLast
522 {mso-style-priority:10;
523 mso-style-unhide:no;
524 mso-style-qformat:yes;
525 mso-style-link:"Title Char";
526 mso-style-next:Normal;
527 mso-style-type:export-only;
528 margin-top:0in;
529 margin-right:0in;
530 margin-bottom:15.0pt;
531 margin-left:0in;
532 mso-add-space:auto;
533 mso-pagination:widow-orphan;
534 border:none;
535 mso-border-bottom-alt:solid #4F81BD 1.0pt;
536 mso-border-bottom-themecolor:accent1;
537 padding:0in;
538 mso-padding-alt:0in 0in 4.0pt 0in;
539 font-size:26.0pt;
540 font-family:"Cambria","serif";
541 mso-ascii-font-family:Cambria;
542 mso-ascii-theme-font:major-latin;
543 mso-fareast-font-family:"Times New Roman";
544 mso-fareast-theme-font:major-fareast;
545 mso-hansi-font-family:Cambria;
546 mso-hansi-theme-font:major-latin;
547 mso-bidi-font-family:"Times New Roman";
548 mso-bidi-theme-font:major-bidi;
549 color:#17365D;
550 mso-themecolor:text2;
551 mso-themeshade:191;
552 letter-spacing:.25pt;
553 mso-font-kerning:14.0pt;}
554a:link, span.MsoHyperlink
555 {mso-style-priority:99;
556 color:blue;
557 mso-themecolor:hyperlink;
558 text-decoration:underline;
559 text-underline:single;}
560a:visited, span.MsoHyperlinkFollowed
561 {mso-style-noshow:yes;
562 mso-style-priority:99;
563 color:purple;
564 mso-themecolor:followedhyperlink;
565 text-decoration:underline;
566 text-underline:single;}
567code
568 {mso-style-noshow:yes;
569 mso-style-priority:99;
570 font-family:"Courier New";
571 mso-ascii-font-family:"Courier New";
572 mso-fareast-font-family:"Times New Roman";
573 mso-hansi-font-family:"Courier New";
574 mso-bidi-font-family:"Courier New";}
575pre
576 {mso-style-noshow:yes;
577 mso-style-priority:99;
578 mso-style-link:"HTML Preformatted Char";
579 margin:0in;
580 margin-bottom:.0001pt;
581 mso-pagination:widow-orphan;
582 font-size:10.0pt;
583 font-family:"Courier New";
584 mso-fareast-font-family:"Times New Roman";}
585p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
586 {mso-style-noshow:yes;
587 mso-style-priority:99;
588 mso-style-link:"Balloon Text Char";
589 margin:0in;
590 margin-bottom:.0001pt;
591 mso-pagination:widow-orphan;
592 font-size:8.0pt;
593 font-family:"Tahoma","sans-serif";
594 mso-fareast-font-family:Calibri;
595 mso-fareast-theme-font:minor-latin;}
596span.MsoBookTitle
597 {mso-style-priority:33;
598 mso-style-unhide:no;
599 mso-style-qformat:yes;
600 font-variant:small-caps;
601 letter-spacing:.25pt;
602 font-weight:bold;}
603span.Heading1Char
604 {mso-style-name:"Heading 1 Char";
605 mso-style-priority:9;
606 mso-style-unhide:no;
607 mso-style-locked:yes;
608 mso-style-link:"Heading 1";
609 mso-ansi-font-size:14.0pt;
610 mso-bidi-font-size:14.0pt;
611 font-family:"Cambria","serif";
612 mso-ascii-font-family:Cambria;
613 mso-ascii-theme-font:major-latin;
614 mso-fareast-font-family:"Times New Roman";
615 mso-fareast-theme-font:major-fareast;
616 mso-hansi-font-family:Cambria;
617 mso-hansi-theme-font:major-latin;
618 mso-bidi-font-family:"Times New Roman";
619 mso-bidi-theme-font:major-bidi;
620 color:#365F91;
621 mso-themecolor:accent1;
622 mso-themeshade:191;
623 font-weight:bold;}
624span.HTMLPreformattedChar
625 {mso-style-name:"HTML Preformatted Char";
626 mso-style-noshow:yes;
627 mso-style-priority:99;
628 mso-style-unhide:no;
629 mso-style-locked:yes;
630 mso-style-link:"HTML Preformatted";
631 mso-ansi-font-size:10.0pt;
632 mso-bidi-font-size:10.0pt;
633 font-family:"Courier New";
634 mso-ascii-font-family:"Courier New";
635 mso-fareast-font-family:"Times New Roman";
636 mso-hansi-font-family:"Courier New";
637 mso-bidi-font-family:"Courier New";}
638span.TitleChar
639 {mso-style-name:"Title Char";
640 mso-style-priority:10;
641 mso-style-unhide:no;
642 mso-style-locked:yes;
643 mso-style-link:Title;
644 mso-ansi-font-size:26.0pt;
645 mso-bidi-font-size:26.0pt;
646 font-family:"Cambria","serif";
647 mso-ascii-font-family:Cambria;
648 mso-ascii-theme-font:major-latin;
649 mso-fareast-font-family:"Times New Roman";
650 mso-fareast-theme-font:major-fareast;
651 mso-hansi-font-family:Cambria;
652 mso-hansi-theme-font:major-latin;
653 mso-bidi-font-family:"Times New Roman";
654 mso-bidi-theme-font:major-bidi;
655 color:#17365D;
656 mso-themecolor:text2;
657 mso-themeshade:191;
658 letter-spacing:.25pt;
659 mso-font-kerning:14.0pt;}
660span.BalloonTextChar
661 {mso-style-name:"Balloon Text Char";
662 mso-style-noshow:yes;
663 mso-style-priority:99;
664 mso-style-unhide:no;
665 mso-style-locked:yes;
666 mso-style-link:"Balloon Text";
667 mso-ansi-font-size:8.0pt;
668 mso-bidi-font-size:8.0pt;
669 font-family:"Tahoma","sans-serif";
670 mso-ascii-font-family:Tahoma;
671 mso-hansi-font-family:Tahoma;
672 mso-bidi-font-family:Tahoma;}
673span.type
674 {mso-style-name:type;
675 mso-style-unhide:no;}
676span.comment
677 {mso-style-name:comment;
678 mso-style-unhide:no;}
679span.apple-converted-space
680 {mso-style-name:apple-converted-space;
681 mso-style-unhide:no;}
682span.SpellE
683 {mso-style-name:"";
684 mso-spl-e:yes;}
685span.GramE
686 {mso-style-name:"";
687 mso-gram-e:yes;}
688.MsoChpDefault
689 {mso-style-type:export-only;
690 mso-default-props:yes;
691 font-size:10.0pt;
692 mso-ansi-font-size:10.0pt;
693 mso-bidi-font-size:10.0pt;
694 mso-ascii-font-family:Calibri;
695 mso-ascii-theme-font:minor-latin;
696 mso-fareast-font-family:Calibri;
697 mso-fareast-theme-font:minor-latin;
698 mso-hansi-font-family:Calibri;
699 mso-hansi-theme-font:minor-latin;
700 mso-bidi-font-family:"Times New Roman";
701 mso-bidi-theme-font:minor-bidi;}
702@page WordSection1
703 {size:8.5in 11.0in;
704 margin:1.0in 1.0in 1.0in 1.0in;
705 mso-header-margin:.5in;
706 mso-footer-margin:.5in;
707 mso-paper-source:0;}
708div.WordSection1
709 {page:WordSection1;}
710-->
711</style>
712<!--[if gte mso 10]>
713<style>
714 /* Style Definitions */
715 table.MsoNormalTable
716 {mso-style-name:"Table Normal";
717 mso-tstyle-rowband-size:0;
718 mso-tstyle-colband-size:0;
719 mso-style-noshow:yes;
720 mso-style-priority:99;
721 mso-style-qformat:yes;
722 mso-style-parent:"";
723 mso-padding-alt:0in 5.4pt 0in 5.4pt;
724 mso-para-margin:0in;
725 mso-para-margin-bottom:.0001pt;
726 mso-pagination:widow-orphan;
727 font-size:10.0pt;
728 font-family:"Calibri","sans-serif";
729 mso-ascii-font-family:Calibri;
730 mso-ascii-theme-font:minor-latin;
731 mso-hansi-font-family:Calibri;
732 mso-hansi-theme-font:minor-latin;
733 mso-bidi-font-family:"Times New Roman";
734 mso-bidi-theme-font:minor-bidi;}
735</style>
736<![endif]--><!--[if gte mso 9]><xml>
737 <o:shapedefaults v:ext="edit" spidmax="6146"/>
738</xml><![endif]--><!--[if gte mso 9]><xml>
739 <o:shapelayout v:ext="edit">
740 <o:idmap v:ext="edit" data="1"/>
741 </o:shapelayout></xml><![endif]-->
742</head>
743
744<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
745
746<div class=WordSection1>
747
748<div style='mso-element:para-border-div;border:none;border-bottom:solid #4F81BD 1.0pt;
749mso-border-bottom-themecolor:accent1;padding:0in 0in 4.0pt 0in'>
750
751<p class=MsoTitle>Symmetric Multi-Processing on Haiku – A Programming Example</p>
752
753</div>
754
755<p class=MsoNormal>By Andrew Hudson</p>
756
757<h1>Multiple Threads and Multiple Cores </h1>
758
759<p class=MsoNormal>BeOS and Haiku were designed from the start to run multiple
760threads on multiple cores.<span style='mso-spacerun:yes'>  </span>The BeOS
761application framework was designed to run multiple threads from its inception
762and the first workstation that ran BeOS had 2 processors.<span
763style='mso-spacerun:yes'>  </span>Some 20 years after BeOS was first released
764PCs with multiple cores are now common place, but applications are still
765struggling to effectively make use of extra cores.<span
766style='mso-spacerun:yes'>  </span>This article will explore one coding
767technique that allows you to easily use all cores.</p>
768
769<p class=MsoNormal>First of all, what is a thread? Wikipedia defines a thread
770as, “<span style='font-size:10.5pt;line-height:115%;font-family:"Arial","sans-serif";
771color:#252525;background:white'>the smallest sequence of programmed instructions
772that can be managed independently by a<span class=apple-converted-space>&nbsp;</span></span><span
773style='font-size:10.5pt;line-height:115%;font-family:"Arial","sans-serif";
774background:white'>scheduler</span>”.<span style='mso-spacerun:yes'>  </span>One
775or more threads can run within a process. A process is the basis for
776multi-tasking and time-sharing. A process has a context or process state, which
777consists of all the <span class=GramE>CPU</span> registers, the code, the data,
778the call stack, open files, etc.<span style='mso-spacerun:yes'>  </span>Threads
779run within a process and share process resources such as variables, memory, <span
780class=GramE>open</span> files.<span style='mso-spacerun:yes'>  </span></p>
781
782<p class=MsoNormal>Threads are useful for managing I/O. Why <span class=GramE>have
783your whole application process</span> lock up while waiting for input from a
784device or a user?<span style='mso-spacerun:yes'>  </span>Threads in Haiku make
785the user interface very responsive, even when the system is under load. </p>
786
787<h1>Thread Functions</h1>
788
789<p class=MsoNormal>Threads under Haiku can be explicitly created, controlled,
790and deleted with a variety of functions:</p>
791
792<p class=MsoNormal><span class=SpellE>spawn_<span class=GramE>thread</span></span><span
793class=GramE>(</span>) – spawn a new thread</p>
794
795<p class=MsoNormal><span class=SpellE>find_<span class=GramE>thread</span></span><span
796class=GramE>(</span>) – look for a thread using its name</p>
797
798<p class=MsoNormal><span class=SpellE>get_thread_<span class=GramE>info</span></span><span
799class=GramE>(</span>) – retrieve info on a thread</p>
800
801<p class=MsoNormal><span class=SpellE>resume_<span class=GramE>thread</span></span><span
802class=GramE>(</span>) – start a thread and return to process, thread runs
803asynchronously</p>
804
805<p class=MsoNormal><span class=SpellE>wait_for_<span class=GramE>thread</span></span><span
806class=GramE>(</span>) – start a thread and wait for it to complete, thread runs
807synchronously</p>
808
809<p class=MsoNormal><span class=GramE>snooze(</span>) – put a thread to sleep
810for a time</p>
811
812<p class=MsoNormal><span class=SpellE>suspend_<span class=GramE>thread</span></span><span
813class=GramE>(</span>) – suspend execution of a thread</p>
814
815<p class=MsoNormal><span class=SpellE>exit_<span class=GramE>thread</span></span><span
816class=GramE>(</span>) – kill the calling thread</p>
817
818<p class=MsoNormal><span style='mso-spacerun:yes'> </span><span class=SpellE>kill_<span
819class=GramE>thread</span></span><span class=GramE>(</span>) – kill some other
820thread</p>
821
822<p class=MsoNormal><span class=GramE>Additional<span style='mso-spacerun:yes'> 
823</span>functions</span> can be found in the <a
824href="https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_ThreadsAndTeams_Overview.html"><span
825class=SpellE>BeBook</span></a>. </p>
826
827<h1>The Challenges of Thread Programming</h1>
828
829<p class=MsoNormal>Usually programming with threads means very careful
830attention to a whole variety of issues. Synchronization, race conditions,
831deadlocks, variables going out of scope, <span class=GramE>are</span> just some
832of the many things that can cause bugs. Multi-threaded programming bugs can be
833very subtle. A program might run fine on your development system, but become
834intermittently erratic on another PC.<span style='mso-spacerun:yes'>  </span>Or
835it might run fine 19 out of 20 times, and deliver an incorrect result once out
836of 20 runs.<span style='mso-spacerun:yes'>  </span>Multi-threaded programs can
837also be difficult to debug because the debugger can alter the threading state,
838changing the conditions that caused the bug. Fortunately, few of these
839conditions apply to this example. </p>
840
841<h1>Haiku’s New Scheduler</h1>
842
843<p class=MsoNormal>In February of 2014, Haiku updated its scheduler. Up to that
844point, BeOS and Haiku had been limited to a maximum of 8 cores. The new
845scheduler allows you can use up to 64 cores. As someone interested in graphics,
846multiple cores, and Haiku, I thought it would be fun to write a Haiku
847application that would use multiple cores and create some fun graphics. This
848was the start of <span class=SpellE>BeTracer</span>, a ray tracer using
849symmetric multi-processing.</p>
850
851<h1>Using an Old Technique - Mandelbrot</h1>
852
853<p class=MsoNormal>Mandelbrot is a nice demo that ships with Haiku and nicely
854shows off symmetrical multi-processing for 2 cores. If you haven’t tried it
855recently, watch carefully the next time you run it. You will notice that the
856screen updates two separate rows at a time. Mandelbrot uses a simple technique
857for multiple threads. It does this by duplicating the same rendering code into
858two functions, and calls one for even lines and the other for odd lines. </p>
859
860<div style='mso-element:para-border-div;border:solid #D5D5D5 1.0pt;mso-border-alt:
861solid #D5D5D5 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#FAFAFA;
862margin-left:24.0pt;margin-right:24.0pt'>
863
864<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
865margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
866background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
867mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
868font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
869
870<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
871margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
872background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
873mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
874style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
875color:black'>void</span></span><span style='font-size:10.0pt;font-family:"Courier New";
876mso-fareast-font-family:"Times New Roman";color:black'> <span class=SpellE>TShowBit</span>::<span
877class=SpellE>mand</span>(double <span class=SpellE>vx</span>, double <span
878class=SpellE>vy</span>, double <span class=SpellE>sx</span>, double <span
879class=SpellE>sy</span>)<o:p></o:p></span></p>
880
881<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
882margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
883background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
884mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
885font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>{<o:p></o:p></span></p>
886
887<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
888margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
889background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
890mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
891font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
892style='mso-tab-count:1'>    </span><span class=SpellE><span class=GramE>vvx</span></span>
893= <span class=SpellE>vx</span>; <span class=SpellE>vvy</span> = <span
894class=SpellE>vy</span>; <span class=SpellE>ssx</span> = <span class=SpellE>sx</span>;<o:p></o:p></span></p>
895
896<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
897margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
898background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
899mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
900font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
901style='mso-tab-count:1'>    </span>t1_done = 0; t2_done = 0;<o:p></o:p></span></p>
902
903<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
904margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
905background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
906mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
907font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
908
909<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
910margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
911background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
912mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
913font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
914style='mso-tab-count:1'>    </span><span class=SpellE><span class=GramE>precompute</span></span><span
915class=GramE>(</span><span class=SpellE>vx</span>, <span class=SpellE>vy</span>,
916<span class=SpellE>sx</span>, <span class=SpellE>sy</span>);<o:p></o:p></span></p>
917
918<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
919margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
920background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
921mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
922font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
923style='mso-tab-count:1'>    </span><o:p></o:p></span></p>
924
925<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
926margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
927background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
928mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
929font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
930style='mso-tab-count:1'>    </span><span class=SpellE>resume_<span class=GramE>thread</span></span><span
931class=GramE>(</span><span class=SpellE>spawn_thread</span>(__calc1,
932&quot;calc1&quot;, B_NORMAL_PRIORITY, NULL));<o:p></o:p></span></p>
933
934<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
935margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
936background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
937mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
938font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
939style='mso-tab-count:1'>    </span><span class=SpellE>resume_<span class=GramE>thread</span></span><span
940class=GramE>(</span><span class=SpellE>spawn_thread</span>(__calc2,
941&quot;calc2&quot;, B_NORMAL_PRIORITY, NULL));<o:p></o:p></span></p>
942
943<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
944margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
945background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
946mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
947font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
948style='mso-tab-count:1'>    </span><span class=GramE>busy</span> = TRUE;<o:p></o:p></span></p>
949
950<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
951margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
952background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
953mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
954font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>}<o:p></o:p></span></p>
955
956</div>
957
958<p class=MsoNormal>__calc1 and __calc2 are pointers to functions that are
959identical. Line for line they are the same code. </p>
960
961<p class=MsoNormal>The result is that the Mandelbrot demo runs twice as fast
962when you have 2 cores. The downside is that to support additional cores, you
963have to duplicate the rendering code that many more times. As an exercise I
964rewrote the demo to use 4 functions and use 4 cores. It did work, but it does
965not scale well and it is not elegant. It’s not how the professionals do
966rendering.</p>
967
968<h1>Using a BeOS Pattern </h1>
969
970<p class=MsoNormal>Haiku is a great platform to learn programming. There are a
971lot of great programming resources to be found with a quick search. I highly
972recommend browsing through the old Be Newsletters, and looking through the old
973BeOS sample code. There are plenty of code samples with explanations by the
974original BeOS team. While browsing through the old Be Newsletters, I came
975across a bare-bones C++ class that would launch multiple threads. When I read
976it, a light bulb went off in my head. This was what I needed to implement
977symmetric multi-processing code.</p>
978
979<p class=MsoNormal>The class is called <span class=SpellE>ThreadPrimitive</span>
980and it packs a lot into one class:</p>
981
982<div style='mso-element:para-border-div;border:solid #D5D5D5 1.0pt;mso-border-alt:
983solid #D5D5D5 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#FAFAFA;
984margin-left:24.0pt;margin-right:24.0pt'>
985
986<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
987margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
988background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
989mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
990style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
991color:black'>class</span></span><span style='font-size:10.0pt;font-family:"Courier New";
992mso-fareast-font-family:"Times New Roman";color:black'> </span><span
993class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
994font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:darkgreen'>ThreadPrimitive</span></span><span
995style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
996color:black'> {<o:p></o:p></span></p>
997
998<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
999margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1000background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1001mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1002style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1003color:black'>public</span></span><span style='font-size:10.0pt;font-family:
1004"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>:<o:p></o:p></span></p>
1005
1006<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1007margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1008background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1009mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1010font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1011
1012<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1013margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1014background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1015mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1016font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1017style='mso-spacerun:yes'>  </span></span><span class=SpellE><span class=GramE><span
1018style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1019mso-fareast-font-family:"Times New Roman";color:purple'>ThreadPrimitive</span></span></span><span
1020class=GramE><span style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:
1021"Times New Roman";color:black'>(</span></span><span style='font-size:10.0pt;
1022font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:#5C5F05'>int32</span><span
1023style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1024color:black'> </span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1025font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:#991122'>priority</span><span
1026style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1027color:black'> = </span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1028font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:blue'>B_LOW_PRIORITY</span><span
1029style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1030color:black'>, </span><span style='font-size:10.0pt;font-family:"Courier New";
1031mso-fareast-font-family:"Times New Roman";color:#5C5F05'>const char *</span><span
1032style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1033mso-fareast-font-family:"Times New Roman";color:#991122'>name</span><span
1034style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1035color:black'> = 0):<span style='mso-spacerun:yes'>  </span></span><span
1036class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1037font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>scanThread</span></span><span
1038style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1039color:black'>(-1), </span><span style='font-size:10.0pt;mso-bidi-font-size:
104011.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1041color:navy'>priority</span><span style='font-size:10.0pt;font-family:"Courier New";
1042mso-fareast-font-family:"Times New Roman";color:black'>(</span><span
1043style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1044mso-fareast-font-family:"Times New Roman";color:#991122'>priority</span><span
1045style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1046color:black'>), </span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1047font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>name</span><span
1048style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1049color:black'>(</span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1050font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:#991122'>name</span><span
1051style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1052color:black'>)<o:p></o:p></span></p>
1053
1054<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1055margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1056background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1057mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1058font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1059style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></p>
1060
1061<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1062margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1063background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1064mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1065font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1066style='mso-tab-count:1'>    </span>}<o:p></o:p></span></p>
1067
1068<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1069margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1070background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1071mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1072font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1073
1074<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1075margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1076background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1077mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1078font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1079style='mso-spacerun:yes'>  </span><span class=GramE>virtual</span> </span><span
1080style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1081mso-fareast-font-family:"Times New Roman";color:purple'>~<span class=SpellE>ThreadPrimitive</span></span><span
1082style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1083color:black'>(){<o:p></o:p></span></p>
1084
1085<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1086margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1087background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1088mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1089font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1090style='mso-spacerun:yes'>      </span><span class=GramE>if</span> (</span><span
1091class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1092font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>scanThread</span></span><span
1093style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1094color:black'> &gt; 0) {<o:p></o:p></span></p>
1095
1096<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1097margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1098background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1099mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1100font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1101style='mso-spacerun:yes'>        </span></span><span class=SpellE><span
1102style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1103mso-fareast-font-family:"Times New Roman";color:teal'>kill_<span class=GramE>thread</span></span></span><span
1104class=GramE><span style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:
1105"Times New Roman";color:black'>(</span></span><span class=SpellE><span
1106style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1107mso-fareast-font-family:"Times New Roman";color:navy'>scanThread</span></span><span
1108style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1109color:black'>);<o:p></o:p></span></p>
1110
1111<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1112margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1113background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1114mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1115font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1116style='mso-spacerun:yes'>        </span><span class=GramE>ASSERT(</span>!&quot;<span
1117class=GramE>should</span> not be here&quot;);<o:p></o:p></span></p>
1118
1119<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1120margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1121background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1122mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1123font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1124style='mso-spacerun:yes'>      </span>}<o:p></o:p></span></p>
1125
1126<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1127margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1128background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1129mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1130font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1131style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></p>
1132
1133<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1134margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1135background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1136mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1137font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1138
1139<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1140margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1141background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1142mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1143font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1144style='mso-spacerun:yes'>  </span></span><span class=GramE><span
1145style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1146color:#5C5F05'>void</span></span><span style='font-size:10.0pt;font-family:
1147"Courier New";mso-fareast-font-family:"Times New Roman";color:black'> </span><span
1148style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1149mso-fareast-font-family:"Times New Roman";color:purple'>Go</span><span
1150style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1151color:black'>()<o:p></o:p></span></p>
1152
1153<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1154margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1155background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1156mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1157font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1158style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></p>
1159
1160<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1161margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1162background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1163mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1164font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1165style='mso-spacerun:yes'>      </span></span><span class=SpellE><span
1166class=GramE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:
1167"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>scanThread</span></span></span><span
1168style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1169color:black'> = </span><span class=SpellE><span style='font-size:10.0pt;
1170mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1171"Times New Roman";color:teal'>spawn_thread</span></span><span style='font-size:
117210.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1173color:black'>(&amp;</span><span class=SpellE><span style='font-size:10.0pt;
1174mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1175"Times New Roman";color:darkgreen'>ThreadPrimitive</span></span><span
1176style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1177color:black'>::</span><span class=SpellE><span style='font-size:10.0pt;
1178mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1179"Times New Roman";color:purple'>RunBinder</span></span><span style='font-size:
118010.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1181color:black'>,<o:p></o:p></span></p>
1182
1183<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1184margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1185background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1186mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1187font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1188style='mso-spacerun:yes'>        </span></span><span class=GramE><span
1189style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1190mso-fareast-font-family:"Times New Roman";color:navy'>name</span><span
1191style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1192color:black'> ?</span></span><span style='font-size:10.0pt;font-family:"Courier New";
1193mso-fareast-font-family:"Times New Roman";color:black'> </span><span
1194class=GramE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:
1195"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>name</span><span
1196style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1197color:black'> :</span></span><span style='font-size:10.0pt;font-family:"Courier New";
1198mso-fareast-font-family:"Times New Roman";color:black'> &quot;<span
1199class=SpellE>UntitledThread</span>&quot;, </span><span style='font-size:10.0pt;
1200mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1201"Times New Roman";color:navy'>priority</span><span style='font-size:10.0pt;
1202font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>,
1203</span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:
1204"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>this</span><span
1205style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1206color:black'>);<o:p></o:p></span></p>
1207
1208<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1209margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1210background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1211mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1212font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1213style='mso-spacerun:yes'>      </span></span><span class=SpellE><span
1214style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1215mso-fareast-font-family:"Times New Roman";color:teal'>resume_<span class=GramE>thread</span></span></span><span
1216class=GramE><span style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:
1217"Times New Roman";color:black'>(</span></span><span class=SpellE><span
1218style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1219mso-fareast-font-family:"Times New Roman";color:navy'>scanThread</span></span><span
1220style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1221color:black'>);<o:p></o:p></span></p>
1222
1223<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1224margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1225background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1226mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1227font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1228style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></p>
1229
1230<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1231margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1232background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1233mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1234font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1235
1236<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1237margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1238background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1239mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1240font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1241style='mso-spacerun:yes'>  </span><span class=GramE>virtual</span> </span><span
1242style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1243color:#5C5F05'>void</span><span style='font-size:10.0pt;font-family:"Courier New";
1244mso-fareast-font-family:"Times New Roman";color:black'> </span><span
1245style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1246mso-fareast-font-family:"Times New Roman";color:purple'>Run</span><span
1247style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1248color:black'>() = 0;<o:p></o:p></span></p>
1249
1250<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1251margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1252background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1253mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1254font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1255
1256<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1257margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1258background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1259mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1260style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1261color:black'>private</span></span><span style='font-size:10.0pt;font-family:
1262"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>:<o:p></o:p></span></p>
1263
1264<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1265margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1266background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1267mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1268font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1269
1270<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1271margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1272background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1273mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1274font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1275style='mso-spacerun:yes'>  </span><span class=GramE>static</span> </span><span
1276class=SpellE><span style='font-size:10.0pt;font-family:"Courier New";
1277mso-fareast-font-family:"Times New Roman";color:#5C5F05'>status_t</span></span><span
1278style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1279color:black'> </span><span class=SpellE><span style='font-size:10.0pt;
1280mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1281"Times New Roman";color:purple'>RunBinder</span></span><span style='font-size:
128210.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1283color:black'>(</span><span style='font-size:10.0pt;font-family:"Courier New";
1284mso-fareast-font-family:"Times New Roman";color:#5C5F05'>void *</span><span
1285class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1286font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:#991122'>castToThis</span></span><span
1287style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1288color:black'>)<o:p></o:p></span></p>
1289
1290<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1291margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1292background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1293mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1294font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1295style='mso-spacerun:yes'>    </span>{<o:p></o:p></span></p>
1296
1297<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1298margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1299background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1300mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1301font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1302style='mso-spacerun:yes'>      </span></span><span style='font-size:10.0pt;
1303font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:green'>//
1304<span class=GramE>In</span> this call we do the dirty casting work, making</span><span
1305style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1306color:black'><o:p></o:p></span></p>
1307
1308<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1309margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1310background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1311mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1312font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1313style='mso-spacerun:yes'>      </span></span><span style='font-size:10.0pt;
1314font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:green'>//
1315the rest of the interfaces fully typed and clean</span><span style='font-size:
131610.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1317color:black'><o:p></o:p></span></p>
1318
1319<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1320margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1321background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1322mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1323font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1324
1325<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1326margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1327background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1328mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1329font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1330style='mso-spacerun:yes'>      </span></span><span class=SpellE><span
1331style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1332mso-fareast-font-family:"Times New Roman";color:darkgreen'>ThreadPrimitive</span></span><span
1333style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1334color:#5C5F05'> *</span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1335font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:navy'>self</span><span
1336style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1337color:black'> = (</span><span class=SpellE><span style='font-size:10.0pt;
1338mso-bidi-font-size:11.0pt;font-family:"Courier New";mso-fareast-font-family:
1339"Times New Roman";color:darkgreen'>ThreadPrimitive</span></span><span
1340style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1341color:#5C5F05'> *</span><span class=GramE><span style='font-size:10.0pt;
1342font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>)</span><span
1343class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1344font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:#991122'>castToThis</span></span></span><span
1345style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1346color:black'>;<o:p></o:p></span></p>
1347
1348<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1349margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1350background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1351mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1352font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1353style='mso-spacerun:yes'>      </span></span><span class=GramE><span
1354style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1355mso-fareast-font-family:"Times New Roman";color:navy'>self</span></span><span
1356style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1357color:black'>-&gt;</span><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
1358font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:purple'>Run</span><span
1359style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1360color:black'>();<o:p></o:p></span></p>
1361
1362<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1363margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1364background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1365mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1366font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1367
1368<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1369margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1370background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1371mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1372font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1373style='mso-spacerun:yes'>      </span><span class=GramE>return</span> </span><span
1374style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1375mso-fareast-font-family:"Times New Roman";color:blue'>B_OK</span><span
1376style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1377color:black'>;<o:p></o:p></span></p>
1378
1379<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1380margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1381background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1382mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1383font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1384style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></p>
1385
1386<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1387margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1388background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1389mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1390font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1391
1392<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1393margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1394background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1395mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1396style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1397color:black'>protected</span></span><span style='font-size:10.0pt;font-family:
1398"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>:<o:p></o:p></span></p>
1399
1400<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1401margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1402background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1403mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1404font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1405style='mso-spacerun:yes'>  </span></span><span class=SpellE><span class=GramE><span
1406style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1407color:#5C5F05'>thread_id</span></span></span><span style='font-size:10.0pt;
1408font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>
1409</span><span class=SpellE><span style='font-size:10.0pt;mso-bidi-font-size:
141011.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1411color:navy'>scanThread</span></span><span style='font-size:10.0pt;font-family:
1412"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>;<o:p></o:p></span></p>
1413
1414<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1415margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1416background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1417mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1418font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1419style='mso-spacerun:yes'>  </span></span><span class=GramE><span
1420style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1421color:#5C5F05'>int32</span></span><span style='font-size:10.0pt;font-family:
1422"Courier New";mso-fareast-font-family:"Times New Roman";color:black'> </span><span
1423style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1424mso-fareast-font-family:"Times New Roman";color:navy'>priority</span><span
1425style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1426color:black'>;<o:p></o:p></span></p>
1427
1428<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1429margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1430background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1431mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1432font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1433
1434<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1435margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1436background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1437mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1438style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1439color:black'>private</span></span><span style='font-size:10.0pt;font-family:
1440"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>:<o:p></o:p></span></p>
1441
1442<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1443margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1444background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1445mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1446font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1447style='mso-spacerun:yes'>  </span></span><span class=GramE><span
1448style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1449color:#5C5F05'>const</span></span><span style='font-size:10.0pt;font-family:
1450"Courier New";mso-fareast-font-family:"Times New Roman";color:#5C5F05'> char *</span><span
1451style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:"Courier New";
1452mso-fareast-font-family:"Times New Roman";color:navy'>name</span><span
1453style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1454color:black'>;<span style='mso-spacerun:yes'>  </span></span><span
1455style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1456color:green'>// only valid in the constructor and in</span><span
1457style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1458color:black'><o:p></o:p></span></p>
1459
1460<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1461margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1462background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1463mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1464font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1465style='mso-spacerun:yes'>                     </span></span><span
1466style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1467color:green'>// the Go call</span><span style='font-size:10.0pt;font-family:
1468"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p></o:p></span></p>
1469
1470<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1471margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1472background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1473mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1474font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>};<o:p></o:p></span></p>
1475
1476</div>
1477
1478<p class=MsoNormal><o:p>&nbsp;</o:p></p>
1479
1480<p class=MsoNormal><span class=SpellE>ThreadPrimitive</span> is an abstract
1481base class and has two important aspects. The constructor and <span
1482class=GramE>Go(</span>)<span style='mso-spacerun:yes'>  </span>method set up
1483the thread context, and Run() is <span class=SpellE>subclassed</span> with code
1484for useful work.<span style='mso-spacerun:yes'>  </span>In other words, your
1485code inherits from <span class=SpellE>ThreadPrimitive</span>, and your code
1486goes in <span class=GramE>Run(</span>). <span style='mso-spacerun:yes'> </span><span
1487class=SpellE><span class=GramE>RunBinder</span></span><span class=GramE>(</span>)
1488takes Run(), casts it to a function pointer, and which is passed to the thread
1489for execution. In this way you can call your own code with as many threads as
1490you want with whatever parameters you need. This is what I used for the basis of
1491my code. </p>
1492
1493<h1>Adding Threads <span class=GramE>To</span> Ray Tracing</h1>
1494
1495<p class=MsoNormal>Ray tracing is a very cool technique used for rendering
1496photorealistic 3D scenes. It is based on an algorithm for firing off light rays
1497from a source, bouncing them off 3D objects, and tracing the ray of light back
1498to a point of view. It is considered to be an “embarrassingly easy” algorithm
1499to parallelize.<span style='mso-spacerun:yes'>  </span>This means it does not
1500require any of the usual methods used to synchronize and control threads. Some
1501of those techniques are discussed <a
1502href="https://www.haiku-os.org/documents/dev/understanding_the_design_and_requirements_of_multithreaded_applications">here</a>.<span
1503style='mso-spacerun:yes'>  </span><span class=SpellE>Raytracing</span> was
1504first made popular with the famous juggling balls demo on the Amiga.</p>
1505
1506<p class=MsoNormal><span style='mso-spacerun:yes'> </span>I didn’t want to
1507re-invent the ray tracing wheel, as it were, so I began looking at source code
1508I could use for ray tracing. I looked at, ported, and discarded 5
1509implementations before settling <a href="http://www.povworld.org/raytracer/">on
1510Micha Riser’s Ray-Tracer code</a>. This was after stumbling across <span
1511class=SpellE>Micha’s</span> long lost <a
1512href="http://oxben.free.fr/povray-beos.html">BeOS implementation of POV3.1</a>.<span
1513style='mso-spacerun:yes'>  </span></p>
1514
1515<p class=MsoNormal><span class=SpellE>Micha’s</span> code was well-written,
1516easily ported, and single threaded. The key to converting this code to multiple
1517threads was to map an equal portion of each image rendering onto each thread.
1518This was done by <span class=SpellE>parameterizing</span> each thread call with
1519a sub class named <span class=SpellE>RenderThread</span>.<span
1520style='mso-spacerun:yes'>  </span><span class=SpellE>RenderThread</span> would
1521know how big the image was, how many threads there were, and parcel an equal
1522piece of the image to each thread. The scheduler would then run each thread on
1523a separate core. The cool thing about multi-threaded ray tracing is that you
1524watch each thread render its results to the screen in real time. Each
1525additional processor you add means the rendering is that much faster.</p>
1526
1527<p class=MsoNormal><o:p>&nbsp;</o:p></p>
1528
1529<p class=MsoNormal>From MainWindow.cpp, we start a thread for each <span
1530class=GramE>core,</span> pass in enough parameters for processing:</p>
1531
1532<div style='mso-element:para-border-div;border:solid #D5D5D5 1.0pt;mso-border-alt:
1533solid #D5D5D5 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#FAFAFA;
1534margin-left:24.0pt;margin-right:24.0pt'>
1535
1536<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1537margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1538background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1539mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1540style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1541color:black'>for</span></span><span style='font-size:10.0pt;font-family:"Courier New";
1542mso-fareast-font-family:"Times New Roman";color:black'> (<span class=SpellE>i</span>=0;
1543<span class=SpellE>i</span>&lt;<span class=SpellE>NumThreads</span>; <span
1544class=SpellE>i</span>++){<o:p></o:p></span></p>
1545
1546<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1547margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1548background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1549mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1550font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1551style='mso-spacerun:yes'>    </span><span class=SpellE>RenderThread</span>::<span
1552class=GramE>Launch(</span>scene, pout, <span class=SpellE>XRes</span>, <span
1553class=SpellE>YRes</span>, <span class=SpellE>Xloc</span>, <span class=SpellE>Yloc</span>,
1554<span class=SpellE>Zloc</span>,<o:p></o:p></span></p>
1555
1556<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1557margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1558background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1559mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1560font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1561style='mso-spacerun:yes'>        </span><span class=SpellE>NumThreads</span>, <span
1562class=SpellE>i</span>, (<span class=SpellE>uchar</span> *<span class=GramE>)<span
1563class=SpellE>theBitmap</span></span>-&gt;Bits(), <o:p></o:p></span></p>
1564
1565<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1566margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1567background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1568mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1569font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1570style='mso-tab-count:1'>    </span><span style='mso-spacerun:yes'>   
1571</span>B_LOW_PRIORITY, &quot;thread&quot;);<o:p></o:p></span></p>
1572
1573<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1574margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1575background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1576mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1577font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>}<o:p></o:p></span></p>
1578
1579</div>
1580
1581<p class=MsoNormal><span style='font-family:"Courier New"'><span
1582style='mso-tab-count:3'>                </span></span></p>
1583
1584<p class=MsoNormal><span style='mso-spacerun:yes'>    </span>From
1585RenderThread.cpp, the inner loop of rendering, for each thread:</p>
1586
1587<div style='mso-element:para-border-div;border:solid #D5D5D5 1.0pt;mso-border-alt:
1588solid #D5D5D5 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#FAFAFA;
1589margin-left:24.0pt;margin-right:24.0pt'>
1590
1591<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1592margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1593background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1594mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1595font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'>//do
1596rendering<span style='mso-spacerun:yes'>     </span><o:p></o:p></span></p>
1597
1598<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1599margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1600background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1601mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
1602style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman";
1603color:black'>void</span></span><span style='font-size:10.0pt;font-family:"Courier New";
1604mso-fareast-font-family:"Times New Roman";color:black'> <span class=SpellE>RenderThread</span>::Run(){<o:p></o:p></span></p>
1605
1606<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1607margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1608background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1609mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1610font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1611style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>int</span></span>
1612<span class=SpellE>y,x</span>;<o:p></o:p></span></p>
1613
1614<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1615margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1616background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1617mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1618font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1619style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>int</span></span>
1620<span class=SpellE>Ychunk</span>, <span class=SpellE>Ystart</span>, <span
1621class=SpellE>Yend</span>;<o:p></o:p></span></p>
1622
1623<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1624margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1625background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1626mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1627font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1628style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>uchar</span></span>
1629*b0;<o:p></o:p></span></p>
1630
1631<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1632margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1633background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1634mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1635font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1636style='mso-spacerun:yes'>     </span>b0 = <span class=SpellE>MyBits</span>;<o:p></o:p></span></p>
1637
1638<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1639margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1640background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1641mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1642font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1643style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'>   </span><o:p></o:p></span></p>
1644
1645<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1646margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1647background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1648mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1649font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1650style='mso-spacerun:yes'>     </span>// outer loop<o:p></o:p></span></p>
1651
1652<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1653margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1654background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1655mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1656font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1657style='mso-tab-count:1'>    </span><span style='mso-spacerun:yes'> </span>// <span
1658class=GramE>Calculate</span> offsets for thread image portion<o:p></o:p></span></p>
1659
1660<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1661margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1662background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1663mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1664font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1665style='mso-spacerun:yes'>     </span><span class=SpellE>Ychunk</span> = <span
1666class=SpellE>YRes</span> / <span class=SpellE>MyTotThreads</span>;<o:p></o:p></span></p>
1667
1668<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1669margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1670background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1671mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1672font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1673style='mso-spacerun:yes'>     </span><span class=SpellE>Ystart</span> = <span
1674class=SpellE>MyWhichThread</span> * <span class=SpellE>Ychunk</span>;<o:p></o:p></span></p>
1675
1676<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1677margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1678background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1679mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1680font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1681style='mso-spacerun:yes'>     </span><span class=SpellE>Yend</span> = <span
1682class=SpellE>Ystart</span> + <span class=SpellE>Ychunk</span>;<o:p></o:p></span></p>
1683
1684<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1685margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1686background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1687mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1688font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1689
1690<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1691margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1692background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1693mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1694font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1695style='mso-spacerun:yes'>     </span><span class=GramE>for</span> (y=<span
1696class=SpellE>Ystart</span>; y&lt;<span class=SpellE>Yend</span>; y++){<o:p></o:p></span></p>
1697
1698<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1699margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1700background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1701mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1702font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1703style='mso-spacerun:yes'>     </span><span style='mso-tab-count:1'>      </span>b0
1704= <span class=SpellE>MyBits</span> + (y*<span class=SpellE>XRes</span>*4); // pointer
1705into thread’s section<o:p></o:p></span></p>
1706
1707<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1708margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1709background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1710mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1711font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1712style='mso-spacerun:yes'>     </span><span style='mso-tab-count:1'>      </span><span
1713class=GramE>for</span> (x=<span class=SpellE>xloc</span>; x&lt;<span
1714class=SpellE>XRes+xloc</span>; x++){<o:p></o:p></span></p>
1715
1716<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1717margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1718background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1719mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1720font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1721style='mso-spacerun:yes'>     </span><span style='mso-tab-count:1'>      </span>//
1722inner loop<o:p></o:p></span></p>
1723
1724<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1725margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1726background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1727mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1728font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1729style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1730</span>// create a point of view vector of X<span class=GramE>,Y,Z</span><o:p></o:p></span></p>
1731
1732<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1733margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1734background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1735mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1736font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1737style='mso-spacerun:yes'>                </span>Vector3 <span class=GramE>pos(</span>
1738((DBL)x+((DBL).5))/<span class=SpellE>XRes</span>, ((DBL)1)-((DBL)<span
1739class=SpellE>y+yloc</span>+((DBL)0.5))/<span class=SpellE>YRes</span>, (DBL)<span
1740class=SpellE>zloc</span>);<o:p></o:p></span></p>
1741
1742<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1743margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1744background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1745mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1746font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1747
1748<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1749margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1750background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1751mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1752font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1753style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1754</span>// trace the ray from light to POV<o:p></o:p></span></p>
1755
1756<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1757margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1758background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1759mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1760font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1761style='mso-spacerun:yes'>                </span><span class=SpellE>ColourA</span>
1762res = <span class=SpellE>imageplane</span>-&gt;<span class=SpellE><span
1763class=GramE>evaluateAt</span></span><span class=GramE>(</span>pos);<o:p></o:p></span></p>
1764
1765<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1766margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1767background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1768mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1769font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1770style='mso-spacerun:yes'> </span><o:p></o:p></span></p>
1771
1772<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1773margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1774background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1775mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1776font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1777style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1778</span>// once calculated, update bitmap with R<span class=GramE>,G,B</span><o:p></o:p></span></p>
1779
1780<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1781margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1782background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1783mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1784font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1785style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1786</span>*b0++ = (<span class=SpellE>uint</span><span class=GramE>)(</span>(std::min(<span
1787class=SpellE>res.c</span>[2],(CLR)1)*255));<o:p></o:p></span></p>
1788
1789<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1790margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1791background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1792mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1793font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1794style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1795</span>*b0++ = (<span class=SpellE>uint</span><span class=GramE>)(</span>(std::min(<span
1796class=SpellE>res.c</span>[1],(CLR)1)*255));<o:p></o:p></span></p>
1797
1798<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1799margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1800background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1801mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1802font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1803style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1804</span>*b0++ = (<span class=SpellE>uint</span><span class=GramE>)(</span>(std::min(<span
1805class=SpellE>res.c</span>[0],(CLR)1)*255));<o:p></o:p></span></p>
1806
1807<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1808margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1809background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1810mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1811font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1812style='mso-tab-count:2'>           </span><span style='mso-spacerun:yes'>   
1813</span>*b0++;<o:p></o:p></span></p>
1814
1815<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1816margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1817background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1818mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1819font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1820style='mso-spacerun:yes'>     </span>}<o:p></o:p></span></p>
1821
1822<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1823margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1824background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1825mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1826font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1827
1828<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1829margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1830background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1831mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1832font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1833style='mso-spacerun:yes'>     </span>// redraw image at the end of every row<o:p></o:p></span></p>
1834
1835<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1836margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1837background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1838mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1839font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1840style='mso-tab-count:1'>    </span><span style='mso-spacerun:yes'> </span>//
1841lock the bitmap so only one thread updates the screen<o:p></o:p></span></p>
1842
1843<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1844margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1845background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1846mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1847font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1848style='mso-tab-count:1'>    </span><span style='mso-spacerun:yes'> </span>// at
1849a time<o:p></o:p></span></p>
1850
1851<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1852margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1853background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1854mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1855font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1856style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>theBitmap</span></span>-&gt;Lock();<o:p></o:p></span></p>
1857
1858<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1859margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1860background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1861mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1862font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1863style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>povView</span></span>-&gt;<span
1864class=SpellE>LockLooper</span>();<o:p></o:p></span></p>
1865
1866<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1867margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1868background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1869mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1870font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1871style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>povView</span></span>-&gt;Invalidate(<span
1872class=SpellE>BRect</span>(0,y,x,y));<o:p></o:p></span></p>
1873
1874<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1875margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1876background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1877mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1878font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1879style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>povView</span></span>-&gt;<span
1880class=SpellE>UnlockLooper</span>();<o:p></o:p></span></p>
1881
1882<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1883margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1884background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1885mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1886font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1887style='mso-spacerun:yes'>     </span><span class=SpellE><span class=GramE>theBitmap</span></span>-&gt;Unlock();<o:p></o:p></span></p>
1888
1889<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1890margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1891background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1892mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1893font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><o:p>&nbsp;</o:p></span></p>
1894
1895<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1896margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1897background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1898mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1899font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1900style='mso-spacerun:yes'>     </span>}<o:p></o:p></span></p>
1901
1902<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1903margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1904background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1905mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1906font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1907style='mso-spacerun:yes'>     </span><span class=GramE>delete</span> this;<o:p></o:p></span></p>
1908
1909<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
1910margin-left:0in;line-height:normal;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
1911background:#FAFAFA;border:none;mso-border-alt:solid #D5D5D5 .75pt;padding:0in;
1912mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span style='font-size:10.0pt;
1913font-family:"Courier New";mso-fareast-font-family:"Times New Roman";color:black'><span
1914style='mso-spacerun:yes'> </span>}<o:p></o:p></span></p>
1915
1916</div>
1917
1918<h1>Adding a GUI</h1>
1919
1920<p class=MsoNormal>I added a simple GUI to the ray tracing code to allow choices
1921for screen size, number of threads, scene selection, basic motion control, and
1922to display the image. The technique for display is to create a single bitmap
1923that would be updated by each thread. Normally you would not want multiple
1924threads updating an object willy-nilly. This would be a source of contention,
1925resulting in lost writes. Normally you would need to enforce orderly updates
1926using semaphores and locks. But in this case each thread is guaranteed to
1927update only its section of the bitmap. For efficiency sake the bitmap is only
1928redrawn at the completion of each line. </p>
1929
1930<h1><span style='font-size:11.0pt;line-height:115%;font-family:"Calibri","sans-serif";
1931mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
1932minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
1933mso-bidi-theme-font:minor-bidi;color:windowtext;font-weight:normal;mso-bidi-font-weight:
1934bold;mso-no-proof:yes'><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
1935 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
1936 filled="f" stroked="f">
1937 <v:stroke joinstyle="miter"/>
1938 <v:formulas>
1939 <v:f eqn="if lineDrawn pixelLineWidth 0"/>
1940 <v:f eqn="sum @0 1 0"/>
1941 <v:f eqn="sum 0 0 @1"/>
1942 <v:f eqn="prod @2 1 2"/>
1943 <v:f eqn="prod @3 21600 pixelWidth"/>
1944 <v:f eqn="prod @3 21600 pixelHeight"/>
1945 <v:f eqn="sum @0 0 1"/>
1946 <v:f eqn="prod @6 1 2"/>
1947 <v:f eqn="prod @7 21600 pixelWidth"/>
1948 <v:f eqn="sum @8 21600 0"/>
1949 <v:f eqn="prod @7 21600 pixelHeight"/>
1950 <v:f eqn="sum @10 21600 0"/>
1951 </v:formulas>
1952 <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
1953 <o:lock v:ext="edit" aspectratio="t"/>
1954</v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_i1026" type="#_x0000_t75"
1955 style='width:467.25pt;height:439.5pt;visibility:visible;mso-wrap-style:square'>
1956 <v:imagedata src="Symmetric%20Multiprocessing%20on%20Haiku%20_files/image001.png"
1957 o:title=""/>
1958</v:shape><![endif]--><![if !vml]><img border=0 width=623 height=586
1959src="Symmetric%20Multiprocessing%20on%20Haiku%20_files/image005.jpg" v:shapes="Picture_x0020_1"><![endif]></span></h1>
1960
1961<h1 align=center style='text-align:center'><span style='font-size:11.0pt;
1962line-height:115%;font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;
1963mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:
1964minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
1965color:windowtext;font-weight:normal'>Screen Shot 1 – Basic Interface<o:p></o:p></span></h1>
1966
1967<p class=MsoNormal><o:p>&nbsp;</o:p></p>
1968
1969<p class=MsoNormal><span style='mso-no-proof:yes'><!--[if gte vml 1]><v:shape
1970 id="Picture_x0020_2" o:spid="_x0000_i1025" type="#_x0000_t75" style='width:467.25pt;
1971 height:439.5pt;visibility:visible;mso-wrap-style:square'>
1972 <v:imagedata src="Symmetric%20Multiprocessing%20on%20Haiku%20_files/image003.png"
1973 o:title=""/>
1974</v:shape><![endif]--><![if !vml]><img border=0 width=623 height=586
1975src="Symmetric%20Multiprocessing%20on%20Haiku%20_files/image006.jpg" v:shapes="Picture_x0020_2"><![endif]></span></p>
1976
1977<p class=MsoNormal align=center style='text-align:center'>Screen Shot 2 – Shows
1978rendering with 4 threads</p>
1979
1980<h1>Future Directions: Real Time Rendering, Cloud Computing, GPU</h1>
1981
1982<p class=MsoNormal><span class=SpellE>Micha’s</span> code was a great place to
1983start. It had the benefits of being portable and very modular. What it didn’t
1984have was the ability to read in scene files.<span style='mso-spacerun:yes'> 
1985</span>It would be nice to create additional 3D scenes and import them. The
1986code is also not the fastest. Other code such as Intel’s <span class=SpellE><span
1987class=GramE>Embree</span></span><span class=GramE> <span
1988style='mso-spacerun:yes'> </span>code</span> are faster, and bring the promise
1989of real-time rendering within reach. </p>
1990
1991<p class=MsoNormal>Another direction is to de-couple the GUI from the
1992rendering, and implement a client/server approach. The GUI would act as a front
1993end client that requests the rendering from another, presumably faster server.
1994The server would render the image and return portions of the image when
1995completed. This is how commercial rendering is done, with thousands of servers
1996sharing the rendering.<span style='mso-spacerun:yes'>  </span>By running Haiku
1997ray trace servers remotely, <span class=GramE>in<span
1998style='mso-spacerun:yes'>  </span>Amazon</span> AWS, for instance, it would be
1999possible to introduce Haiku to cloud computing. </p>
2000
2001<p class=MsoNormal>It should also be possible to add code that uses the
2002processing power of a video card, or GPU, to compute the ray tracing. </p>
2003
2004<p class=MsoNormal>The method to assign image portions to threads in <span
2005class=SpellE>BeTrace</span> is the simplest possible. The down side is that it
2006is not always efficient. A thread could have a portion of an image with little
2007to render. It will finish early and the core will go idle.<span
2008style='mso-spacerun:yes'>  </span>A smarter subdivision method would assign
2009smaller portions of the image for more efficient overall usage of CPU. <span
2010class=GramE>For instance, on a line by line basis.</span> </p>
2011
2012<p class=MsoNormal>POV-Ray and Blender are two open source 3D development
2013applications. It would be great to port them to Haiku. </p>
2014
2015<p class=MsoNormal><span class=SpellE>BeTracer</span> source code is provided
2016in a link in the appendix. </p>
2017
2018<h1>Appendix</h1>
2019
2020<p class=MsoNormal><o:p>&nbsp;</o:p></p>
2021
2022<p class=MsoNormal>Wikipedia Definition of Threads</p>
2023
2024<p class=MsoNormal><a href="https://en.wikipedia.org/wiki/Thread_(computing)">https://en.wikipedia.org/wiki/Thread_(computing)</a></p>
2025
2026<p class=MsoNormal>Be Newsletters</p>
2027
2028<p class=MsoNormal><a href="https://www.haiku-os.org/legacy-docs/benewsletter/">https://www.haiku-os.org/legacy-docs/benewsletter/</a></p>
2029
2030<p class=MsoNormal>Haiku Scheduler</p>
2031
2032<p class=MsoNormal><a
2033href="https://www.haiku-os.org/blog/pawe%C5%82_dziepak/2013-12-20_haiku_meets_9th_processor">https://www.haiku-os.org/blog/pawe%C5%82_dziepak/2013-12-20_haiku_meets_9th_processor</a></p>
2034
2035<p class=MsoNormal>Fun with threads</p>
2036
2037<p class=MsoNormal>What Makes Multi-threaded Programming Hard?</p>
2038
2039<p class=MsoNormal><a
2040href="http://www.futurechips.org/tips-for-power-coders/parallel-programming.html">http://www.futurechips.org/tips-for-power-coders/parallel-programming.html</a></p>
2041
2042<p class=MsoNormal>Haiku Mandelbrot Code</p>
2043
2044<p class=MsoNormal><a
2045href="https://github.com/luciang/haiku/tree/master/src/apps/mandelbrot">https://github.com/luciang/haiku/tree/master/src/apps/mandelbrot</a></p>
2046
2047<p class=MsoNormal>Archived Be Newsletters</p>
2048
2049<p class=MsoNormal><a
2050href="https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-32.html">https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-32.html</a></p>
2051
2052<p class=MsoNormal>Slider code</p>
2053
2054<p class=MsoNormal><a
2055href="https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-9.html">https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-9.html</a></p>
2056
2057<p class=MsoNormal>More slider code, <span class=SpellE>Dynagraph</span> sample
2058code</p>
2059
2060<p class=MsoNormal><a
2061href="https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-22.html">https://www.haiku-os.org/legacy-docs/benewsletter/Issue3-22.html</a></p>
2062
2063<p class=MsoNormal>Intel <span class=SpellE>Embree</span> Optimized Ray Tracing
2064Kernels</p>
2065
2066<p class=MsoNormal><a href="http://embree.github.io/">http://embree.github.io/</a></p>
2067
2068<p class=MsoNormal>POV-Ray</p>
2069
2070<p class=MsoNormal><a href="http://www.povray.org/download/">http://www.povray.org/download/</a></p>
2071
2072<p class=MsoNormal>Blender</p>
2073
2074<p class=MsoNormal><a href="https://www.blender.org/download/">https://www.blender.org/download/</a></p>
2075
2076<p class=MsoNormal><span class=SpellE>BeTracer</span> Source Code</p>
2077
2078<p class=MsoNormal><a
2079href="https://onedrive.live.com/redir?resid=23646DEFC0827C85!33167&amp;authkey=!AC9ascWSzjh5Nik&amp;ithint=file%2ctar">https://onedrive.live.com/redir?resid=23646DEFC0827C85!33167&amp;authkey=!AC9ascWSzjh5Nik&amp;ithint=file%2ctar</a></p>
2080
2081<p class=MsoNormal>A Programmers Introduction to Haiku</p>
2082
2083<p class=MsoNormal><a
2084href="http://www.osnews.com/story/24945/A_Programmer_s_Introduction_to_the_Haiku_OS">http://www.osnews.com/story/24945/A_Programmer_s_Introduction_to_the_Haiku_OS</a></p>
2085
2086<p class=MsoNormal>Writing Applications for Haiku</p>
2087
2088<p class=MsoNormal><a
2089href="http://www.osnews.com/story/22903/Writing_Applications_for_Haiku">http://www.osnews.com/story/22903/Writing_Applications_for_Haiku</a></p>
2090
2091<p class=MsoNormal><o:p>&nbsp;</o:p></p>
2092
2093</div>
2094
2095</body>
2096
2097</html>