Debian Codegraph @

tests/aslts/src/runtime/collections/mt/mutex/worker_thr.asl

raw
1 /*
2 * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 /*
29 * Run only for the Worker threads,
30 * they wait there for the Control
31 * thread says 'all is ready',
32 * 'go further'.
33 *
34 * arg0 - Index of current thread
35 */
36 Method (M116, 1, NotSerialized)
37 {
38 While (0x01)
39 {
40 If (CTL0)
41 {
42 /* Control thread says 'all is ready' */
43
44 Break
45 }
46
47 M201 (Arg0, VB03, "Sleep, waiting for Control thread")
48 M206 (Arg0, SL01)
49 }
50 }
51
52 /*
53 * Infinite loop of the Worker Threads
54 *
55 * arg0 - number of threads
56 * arg1 - ID of current thread
57 * arg2 - Index of current thread
58 * arg3 - the depth of recursion of call
59 */
60 Method (M101, 4, Serialized)
61 {
62 /*
63 * These internal variables are specified only to show that
64 * recursive calls to methods having internal declarations
65 * (as well as Switch operators) of objects works.
66 */
67 Name (I000, 0xABCD0000)
68 Name (I001, 0xABCD0001)
69 Name (I002, 0xABCD0002)
70 Name (I003, 0xABCD0003)
71 Local0 = DerefOf (BS04 [Arg2])
72 If (Local0)
73 {
74 Return ( /* Go everywhere to the exit to "Terminate thread" */
75
76 Zero)
77 }
78
79 /* Wait for Control thread saying 'go further' */
80
81 M116 (Arg2)
82 /*
83 * Local0 - command for worker to be executed
84 *
85 * Local7 - non-zero means to do break after
86 * confirming "I see zero do00".
87 * Keep Local7 zero otherwise.
88 */
89 Local7 = 0x00
90 While (0x01)
91 {
92 If ((Arg2 >= Arg0))
93 {
94 SE00 (Arg2, ER06, "Error er06")
95 }
96
97 /* Determine the command for particular thread */
98
99 Local0 = C100 /* \C100 */
100 /* Control thread allows for worker threads to fulfill their commands */
101
102 If (DO00)
103 {
104 Local1 = DerefOf (BS01 [Arg2])
105 /* This thread doesn't yet fulfill its command */
106
107 If (!Local1)
108 {
109 /* Command to be fulfilled */
110
111 Local0 = DerefOf (BS00 [Arg2])
112 }
113
114 /* Unnecessary */
115
116 If (!DO00)
117 {
118 Local0 = C100 /* \C100 */
119 }
120 }
121
122 If (!DO00)
123 {
124 Local1 = DerefOf (BS02 [Arg2])
125 If (!Local1)
126 {
127 /* Worker thread reports: "I see zero do00" */
128
129 BS02 [Arg2] = RS00 /* \RS00 */
130 If (Local7)
131 {
132 M201 (Arg2, VB03, "Break completed: exit invinitive loop")
133 Break
134 }
135 }
136 }
137
138 Switch (Local0)
139 {
140 Case (0xF0)
141 {
142 /* c100 (Idle thread) */
143 /*
144 * This command is fulfilled by worker thread
145 * without directive of Control thread.
146 */
147 M201 (Arg2, VB03, "Sleep")
148 M206 (Arg2, SL01)
149 BS03 [Arg2] = C100 /* \C100 */
150 }
151 Case (0xF1)
152 {
153 /* c101 */
154
155 M201 (Arg2, VB03, "Break started")
156 BS01 [Arg2] = C101 /* \C101 */
157 /*
158 * se00(3, 0x12345, "")
159 * break
160 *
161 * Note:
162 * Non-zero Local7 means to do break after
163 * confirming "I see zero do00".
164 * Keep Local7 zero in all other entries.
165 */
166 Local7 = 0x01
167 }
168 Case (0xF2)
169 {
170 /* c102 */
171
172 M201 (Arg2, VB03, "Sleep, command")
173 M206 (Arg2, SL01)
174 BS01 [Arg2] = C102 /* \C102 */
175 }
176 Case (0xF3)
177 {
178 /* c103 */
179
180 M201 (Arg2, VB03, "Acquire/Release")
181 /*
182 * Local1 - Level of mutex
183 * Local2 - number of Levels of mutexes (only 1 here)
184 * Local3 - Index of mutex
185 * Local4 - number of mutexes of the same level
186 */
187 Local1 = DerefOf (P200 [Arg2])
188 /* Local2 - number of Levels of mutexes is 1 here, not used */
189
190 Local3 = DerefOf (P202 [Arg2])
191 Local4 = DerefOf (P203 [Arg2])
192 While (Local4)
193 {
194 /* Acquire */
195
196 Local7 = M310 (Arg1, Arg2, Local1, Local3, 0x00, 0x00, 0x01)
197 If (!Local7)
198 {
199 /* Release */
200
201 M311 (Arg1, Arg2, Local1, Local3, 0x00, 0x01)
202 }
203
204 Local4--
205 Local3++
206 }
207
208 BS01 [Arg2] = C103 /* \C103 */
209 Local7 = 0x00 /* keep Local7 zero */
210 }
211 Case (0xF4)
212 {
213 /* c104 */
214
215 M201 (Arg2, VB03, "c104")
216 /*
217 * Local1 - Level of mutex
218 * Local2 - number of Levels of mutexes (only 1 here)
219 * Local3 - Index of mutex
220 * Local4 - number of mutexes of the same level
221 */
222 /* Acquire mutexes from 0 up to 15 level */
223 Local2 = MAX0 /* \MAX0 */
224 Local1 = 0x00
225 While (Local2)
226 {
227 Local3 = DerefOf (P202 [Arg2])
228 Local4 = DerefOf (P203 [Arg2])
229 While (Local4)
230 {
231 M310 (Arg1, Arg2, Local1, Local3, 0x00, 0x00, 0x01)
232 Local4--
233 Local3++
234 }
235
236 Local2--
237 Local1++
238 }
239
240 /* Levels - in the inverse order */
241 /* Release mutexes from 15 down t0 0 level */
242 Local2 = MAX0 /* \MAX0 */
243 Local1 = (MAX0 - 0x01)
244 While (Local2)
245 {
246 Local3 = DerefOf (P202 [Arg2])
247 Local4 = DerefOf (P203 [Arg2])
248 /* Indexes - in the inverse order too */
249
250 Local3 += Local4
251 Local3--
252 While (Local4)
253 {
254 M311 (Arg1, Arg2, Local1, Local3, 0x00, 0x01)
255 Local4--
256 Local3--
257 }
258
259 Local2--
260 Local1--
261 }
262
263 BS01 [Arg2] = C104 /* \C104 */
264 }
265 Case (0xF5)
266 {
267 /* c105 */
268
269 M201 (Arg2, VB03, "Example 0")
270 Local1 = 0x0A
271 While (Local1)
272 {
273 Switch (Arg2)
274 {
275 Case (0x02)
276 {
277 C0AB (Arg1, Arg2)
278 }
279 Case (0x04)
280 {
281 C0AB (Arg1, Arg2)
282 }
283 Case (0x06)
284 {
285 C0AB (Arg1, Arg2)
286 }
287 Default
288 {
289 C0A2 (Arg1, Arg2, 0x01, 0x01, 0x01)
290 }
291
292 }
293
294 Local1--
295 }
296
297 BS01 [Arg2] = C105 /* \C105 */
298 }
299 Case (0xF6)
300 {
301 /* c106 */
302
303 M201 (Arg2, VB03, "Acquire specified set of mutexes")
304 /*
305 * Local0 - auxiliary
306 * Local1 - Level of mutex
307 * Local2 - number of Levels of mutexes (only 1 here)
308 * Local3 - Index of mutex
309 * Local4 - number of mutexes of the same level
310 * Local5 - non-zero means that we generate exceptional condition
311 * Local6 - opcode of TimeOutValue
312 * Local7 - auxiliary
313 */
314 Local1 = DerefOf (P200 [Arg2])
315 Local2 = DerefOf (P201 [Arg2])
316 While (Local2)
317 {
318 Local3 = DerefOf (P202 [Arg2])
319 Local4 = DerefOf (P203 [Arg2])
320 Local5 = DerefOf (P204 [Arg2])
321 Local6 = DerefOf (P205 [Arg2])
322 While (Local4)
323 {
324 Local7 = M111 (Arg1, Arg2, Local5, "Acquire")
325 Local0 = M310 (Arg1, Arg2, Local1, Local3, Local7, Local6, 0x01)
326 M112 (Arg1, Arg2, Local5, Local0)
327 Local4--
328 Local3++
329 }
330
331 Local2--
332 Local1++
333 }
334
335 BS01 [Arg2] = C106 /* \C106 */
336 Local7 = 0x00 /* keep Local7 zero */
337 }
338 Case (0xF7)
339 {
340 /* c107 */
341
342 M201 (Arg2, VB03, "Release specified set of mutexes")
343 /*
344 * Local1 - Level of mutex
345 * Local2 - number of Levels of mutexes (only 1 here)
346 * Local3 - Index of mutex
347 * Local4 - number of mutexes of the same level
348 * Local5 - non-zero means that we generate exceptional condition
349 * Local7 - auxiliary
350 */
351 Local1 = DerefOf (P200 [Arg2])
352 Local2 = DerefOf (P201 [Arg2])
353 /* Levels - in the inverse order */
354
355 Local1 += Local2
356 Local1--
357 While (Local2)
358 {
359 Local3 = DerefOf (P202 [Arg2])
360 Local4 = DerefOf (P203 [Arg2])
361 Local5 = DerefOf (P204 [Arg2])
362 /* Indexes - in the inverse order too */
363
364 Local3 += Local4
365 Local3--
366 While (Local4)
367 {
368 Local7 = M111 (Arg1, Arg2, Local5, "Release")
369 M311 (Arg1, Arg2, Local1, Local3, Local7, 0x01)
370 M112 (Arg1, Arg2, Local5, 0x00)
371 Local4--
372 Local3--
373 }
374
375 Local2--
376 Local1--
377 }
378
379 BS01 [Arg2] = C107 /* \C107 */
380 Local7 = 0x00 /* keep Local7 zero */
381 }
382 Case (0xF8)
383 {
384 /* c108 */
385
386 M201 (Arg2, VB03, "Terminate thread")
387 BS04 [Arg2] = 0x01
388 Break
389 }
390 Case (0xF9)
391 {
392 /* c109 */
393
394 If (!Arg3)
395 {
396 M201 (Arg2, VB03, "Invoke Serialized method")
397 M8FC (Arg0, Arg1, Arg2)
398 }
399 Else
400 {
401 /*
402 * Only after falling down to the second recurcive call
403 * to m101 report that you are completed c109 command and
404 * ready handle following commands.
405 */
406 M201 (Arg2, VB03, "Recursive call to m101 for \'Invoke Serialized method\'")
407 BS01 [Arg2] = C109 /* \C109 */
408 }
409 }
410 Case (0xFA)
411 {
412 /* c10a */
413
414 If (!Arg3)
415 {
416 M201 (Arg2, VB03, "Invoke non-serialized method, use Mutex for critical section")
417 M8FA (Arg0, Arg1, Arg2)
418 }
419 Else
420 {
421 /*
422 * Only after falling down to the second recurcive call
423 * to m101 report that you are completed c109 command and
424 * ready handle following commands.
425 */
426 M201 (Arg2, VB03, "Recursive call to m101 for \'Mutex for critical section\'")
427 BS01 [Arg2] = C10A /* \C10A */
428 }
429 }
430 Case (0xFB)
431 {
432 /* c10b */
433
434 If (!Arg3)
435 {
436 M201 (Arg2, VB03, "Non-serialized method is grabbed simultaneously by several threads")
437 M8F9 (Arg0, Arg1, Arg2)
438 }
439 Else
440 {
441 /*
442 * Only after falling down to the second recurcive call
443 * to m101 report that you are completed c109 command and
444 * ready handle following commands.
445 */
446 M201 (Arg2, VB03, "Recursive call to m101 for \'Non-serialized method\'")
447 BS01 [Arg2] = C10B /* \C10B */
448 }
449 }
450 Default
451 {
452 SE00 (Arg2, ER05, "Error er05")
453 M201 (Arg2, VB03, "Sleep, bad command")
454 Debug = Local0
455 M206 (Arg2, SL01)
456 }
457
458 }
459 }
460 }