1 | Thread Manager |
---|
2 | ############## |
---|
3 | |
---|
4 | Introduction |
---|
5 | ============ |
---|
6 | |
---|
7 | The thread manager implements the functionality required of the thread |
---|
8 | manager as defined by POSIX 1003.1b. This standard requires that |
---|
9 | a compliant operating system provide the facilties to manage multiple |
---|
10 | threads of control and defines the API that must be provided. |
---|
11 | |
---|
12 | The services provided by the thread manager are: |
---|
13 | |
---|
14 | - ``pthread_attr_init`` - Initialize a Thread Attribute Set |
---|
15 | |
---|
16 | - ``pthread_attr_destroy`` - Destroy a Thread Attribute Set |
---|
17 | |
---|
18 | - ``pthread_attr_setdetachstate`` - Set Detach State |
---|
19 | |
---|
20 | - ``pthread_attr_getdetachstate`` - Get Detach State |
---|
21 | |
---|
22 | - ``pthread_attr_setstacksize`` - Set Thread Stack Size |
---|
23 | |
---|
24 | - ``pthread_attr_getstacksize`` - Get Thread Stack Size |
---|
25 | |
---|
26 | - ``pthread_attr_setstackaddr`` - Set Thread Stack Address |
---|
27 | |
---|
28 | - ``pthread_attr_getstackaddr`` - Get Thread Stack Address |
---|
29 | |
---|
30 | - ``pthread_attr_setscope`` - Set Thread Scheduling Scope |
---|
31 | |
---|
32 | - ``pthread_attr_getscope`` - Get Thread Scheduling Scope |
---|
33 | |
---|
34 | - ``pthread_attr_setinheritsched`` - Set Inherit Scheduler Flag |
---|
35 | |
---|
36 | - ``pthread_attr_getinheritsched`` - Get Inherit Scheduler Flag |
---|
37 | |
---|
38 | - ``pthread_attr_setschedpolicy`` - Set Scheduling Policy |
---|
39 | |
---|
40 | - ``pthread_attr_getschedpolicy`` - Get Scheduling Policy |
---|
41 | |
---|
42 | - ``pthread_attr_setschedparam`` - Set Scheduling Parameters |
---|
43 | |
---|
44 | - ``pthread_attr_getschedparam`` - Get Scheduling Parameters |
---|
45 | |
---|
46 | - ``pthread_attr_getaffinity_np`` - Get Thread Affinity Attribute |
---|
47 | |
---|
48 | - ``pthread_attr_setaffinity_np`` - Set Thread Affinity Attribute |
---|
49 | |
---|
50 | - ``pthread_create`` - Create a Thread |
---|
51 | |
---|
52 | - ``pthread_exit`` - Terminate the Current Thread |
---|
53 | |
---|
54 | - ``pthread_detach`` - Detach a Thread |
---|
55 | |
---|
56 | - ``pthread_getattr_np`` - Get Thread Attributes |
---|
57 | |
---|
58 | - ``pthread_join`` - Wait for Thread Termination |
---|
59 | |
---|
60 | - ``pthread_self`` - Get Thread ID |
---|
61 | |
---|
62 | - ``pthread_equal`` - Compare Thread IDs |
---|
63 | |
---|
64 | - ``pthread_once`` - Dynamic Package Initialization |
---|
65 | |
---|
66 | - ``pthread_setschedparam`` - Set Thread Scheduling Parameters |
---|
67 | |
---|
68 | - ``pthread_getschedparam`` - Get Thread Scheduling Parameters |
---|
69 | |
---|
70 | - ``pthread_getaffinity_np`` - Get Thread Affinity |
---|
71 | |
---|
72 | - ``pthread_setaffinity_np`` - Set Thread Affinity |
---|
73 | |
---|
74 | Background |
---|
75 | ========== |
---|
76 | |
---|
77 | Thread Attributes |
---|
78 | ----------------- |
---|
79 | |
---|
80 | Thread attributes are utilized only at thread creation time. A thread |
---|
81 | attribute structure may be initialized and passed as an argument to |
---|
82 | the ``pthread_create`` routine. |
---|
83 | |
---|
84 | *stack address* |
---|
85 | is the address of the optionally user specified stack area for this thread. |
---|
86 | If this value is NULL, then RTEMS allocates the memory for the thread stack |
---|
87 | from the RTEMS Workspace Area. Otherwise, this is the user specified |
---|
88 | address for the memory to be used for the threadâs stack. Each thread must |
---|
89 | have a distinct stack area. Each processor family has different alignment |
---|
90 | rules which should be followed. |
---|
91 | |
---|
92 | *stack size* |
---|
93 | is the minimum desired size for this threadâs stack area. |
---|
94 | If the size of this area as specified by the stack size attribute |
---|
95 | is smaller than the minimum for this processor family and the stack |
---|
96 | is not user specified, then RTEMS will automatically allocate a |
---|
97 | stack of the minimum size for this processor family. |
---|
98 | |
---|
99 | *contention scope* |
---|
100 | specifies the scheduling contention scope. RTEMS only supports the |
---|
101 | PTHREAD_SCOPE_PROCESS scheduling contention scope. |
---|
102 | |
---|
103 | *scheduling inheritance* |
---|
104 | specifies whether a user specified or the scheduling policy and |
---|
105 | parameters of the currently executing thread are to be used. When |
---|
106 | this is PTHREAD_INHERIT_SCHED, then the scheduling policy and |
---|
107 | parameters of the currently executing thread are inherited by |
---|
108 | the newly created thread. |
---|
109 | |
---|
110 | *scheduling policy and parameters* |
---|
111 | specify the manner in which the thread will contend for the processor. |
---|
112 | The scheduling parameters are interpreted based on the specified policy. |
---|
113 | All policies utilize the thread priority parameter. |
---|
114 | |
---|
115 | Operations |
---|
116 | ========== |
---|
117 | |
---|
118 | There is currently no text in this section. |
---|
119 | |
---|
120 | Services |
---|
121 | ======== |
---|
122 | |
---|
123 | This section details the thread managerâs services. |
---|
124 | A subsection is dedicated to each of this managerâs services |
---|
125 | and describes the calling sequence, related constants, usage, |
---|
126 | and status codes. |
---|
127 | |
---|
128 | pthread_attr_init - Initialize a Thread Attribute Set |
---|
129 | ----------------------------------------------------- |
---|
130 | .. index:: pthread_attr_init |
---|
131 | .. index:: initialize a thread attribute set |
---|
132 | |
---|
133 | **CALLING SEQUENCE:** |
---|
134 | |
---|
135 | .. code:: c |
---|
136 | |
---|
137 | #include <pthread.h> |
---|
138 | int pthread_attr_init( |
---|
139 | pthread_attr_t \*attr |
---|
140 | ); |
---|
141 | |
---|
142 | **STATUS CODES:** |
---|
143 | |
---|
144 | *EINVAL* |
---|
145 | The attribute pointer argument is invalid. |
---|
146 | |
---|
147 | **DESCRIPTION:** |
---|
148 | |
---|
149 | The ``pthread_attr_init`` routine initializes the thread attributes |
---|
150 | object specified by ``attr`` with the default value for all of the |
---|
151 | individual attributes. |
---|
152 | |
---|
153 | **NOTES:** |
---|
154 | |
---|
155 | The settings in the default attributes are implementation defined. For |
---|
156 | RTEMS, the default attributes are as follows: |
---|
157 | |
---|
158 | - stackadr |
---|
159 | is not set to indicate that RTEMS is to allocate the stack memory. |
---|
160 | |
---|
161 | - stacksize |
---|
162 | is set to ``PTHREAD_MINIMUM_STACK_SIZE``. |
---|
163 | |
---|
164 | - contentionscope |
---|
165 | is set to ``PTHREAD_SCOPE_PROCESS``. |
---|
166 | |
---|
167 | - inheritsched |
---|
168 | is set to ``PTHREAD_INHERIT_SCHED`` to indicate that the created |
---|
169 | thread inherits its scheduling attributes from its parent. |
---|
170 | |
---|
171 | - detachstate |
---|
172 | is set to ``PTHREAD_CREATE_JOINABLE``. |
---|
173 | |
---|
174 | pthread_attr_destroy - Destroy a Thread Attribute Set |
---|
175 | ----------------------------------------------------- |
---|
176 | .. index:: pthread_attr_destroy |
---|
177 | .. index:: destroy a thread attribute set |
---|
178 | |
---|
179 | **CALLING SEQUENCE:** |
---|
180 | |
---|
181 | .. code:: c |
---|
182 | |
---|
183 | #include <pthread.h> |
---|
184 | int pthread_attr_destroy( |
---|
185 | pthread_attr_t \*attr |
---|
186 | ); |
---|
187 | |
---|
188 | **STATUS CODES:** |
---|
189 | |
---|
190 | *EINVAL* |
---|
191 | The attribute pointer argument is invalid. |
---|
192 | |
---|
193 | *EINVAL* |
---|
194 | The attribute set is not initialized. |
---|
195 | |
---|
196 | **DESCRIPTION:** |
---|
197 | |
---|
198 | The ``pthread_attr_destroy`` routine is used to destroy a thread |
---|
199 | attributes object. The behavior of using an attributes object after |
---|
200 | it is destroyed is implementation dependent. |
---|
201 | |
---|
202 | **NOTES:** |
---|
203 | |
---|
204 | NONE |
---|
205 | |
---|
206 | pthread_attr_setdetachstate - Set Detach State |
---|
207 | ---------------------------------------------- |
---|
208 | .. index:: pthread_attr_setdetachstate |
---|
209 | .. index:: set detach state |
---|
210 | |
---|
211 | **CALLING SEQUENCE:** |
---|
212 | |
---|
213 | .. code:: c |
---|
214 | |
---|
215 | #include <pthread.h> |
---|
216 | int pthread_attr_setdetachstate( |
---|
217 | pthread_attr_t \*attr, |
---|
218 | int detachstate |
---|
219 | ); |
---|
220 | |
---|
221 | **STATUS CODES:** |
---|
222 | |
---|
223 | *EINVAL* |
---|
224 | The attribute pointer argument is invalid. |
---|
225 | |
---|
226 | *EINVAL* |
---|
227 | The attribute set is not initialized. |
---|
228 | |
---|
229 | *EINVAL* |
---|
230 | The detachstate argument is invalid. |
---|
231 | |
---|
232 | **DESCRIPTION:** |
---|
233 | |
---|
234 | The ``pthread_attr_setdetachstate`` routine is used to value of the``detachstate`` attribute. This attribute controls whether the |
---|
235 | thread is created in a detached state. |
---|
236 | |
---|
237 | The ``detachstate`` can be either ``PTHREAD_CREATE_DETACHED`` or``PTHREAD_CREATE_JOINABLE``. The default value for all threads is``PTHREAD_CREATE_JOINABLE``. |
---|
238 | |
---|
239 | **NOTES:** |
---|
240 | |
---|
241 | If a thread is in a detached state, |
---|
242 | then the use of the ID with the ``pthread_detach`` or``pthread_join`` routines is an error. |
---|
243 | |
---|
244 | pthread_attr_getdetachstate - Get Detach State |
---|
245 | ---------------------------------------------- |
---|
246 | .. index:: pthread_attr_getdetachstate |
---|
247 | .. index:: get detach state |
---|
248 | |
---|
249 | **CALLING SEQUENCE:** |
---|
250 | |
---|
251 | .. code:: c |
---|
252 | |
---|
253 | #include <pthread.h> |
---|
254 | int pthread_attr_getdetachstate( |
---|
255 | const pthread_attr_t \*attr, |
---|
256 | int \*detachstate |
---|
257 | ); |
---|
258 | |
---|
259 | **STATUS CODES:** |
---|
260 | |
---|
261 | *EINVAL* |
---|
262 | The attribute pointer argument is invalid. |
---|
263 | |
---|
264 | *EINVAL* |
---|
265 | The attribute set is not initialized. |
---|
266 | |
---|
267 | *EINVAL* |
---|
268 | The detatchstate pointer argument is invalid. |
---|
269 | |
---|
270 | **DESCRIPTION:** |
---|
271 | |
---|
272 | The ``pthread_attr_getdetachstate`` routine is used to obtain the |
---|
273 | current value of the ``detachstate`` attribute as specified |
---|
274 | by the ``attr`` thread attribute object. |
---|
275 | |
---|
276 | **NOTES:** |
---|
277 | |
---|
278 | NONE |
---|
279 | |
---|
280 | pthread_attr_setstacksize - Set Thread Stack Size |
---|
281 | ------------------------------------------------- |
---|
282 | .. index:: pthread_attr_setstacksize |
---|
283 | .. index:: set thread stack size |
---|
284 | |
---|
285 | **CALLING SEQUENCE:** |
---|
286 | |
---|
287 | .. code:: c |
---|
288 | |
---|
289 | #include <pthread.h> |
---|
290 | int pthread_attr_setstacksize( |
---|
291 | pthread_attr_t \*attr, |
---|
292 | size_t stacksize |
---|
293 | ); |
---|
294 | |
---|
295 | **STATUS CODES:** |
---|
296 | |
---|
297 | *EINVAL* |
---|
298 | The attribute pointer argument is invalid. |
---|
299 | |
---|
300 | *EINVAL* |
---|
301 | The attribute set is not initialized. |
---|
302 | |
---|
303 | **DESCRIPTION:** |
---|
304 | |
---|
305 | The ``pthread_attr_setstacksize`` routine is used to set the``stacksize`` attribute in the ``attr`` thread attribute |
---|
306 | object. |
---|
307 | |
---|
308 | **NOTES:** |
---|
309 | |
---|
310 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_ATTR_STACKSIZE`` to indicate that this |
---|
311 | routine is supported. |
---|
312 | |
---|
313 | If the specified stacksize is below the minimum required for this CPU |
---|
314 | (``PTHREAD_STACK_MIN``, then the stacksize will be set to the minimum |
---|
315 | for this CPU. |
---|
316 | |
---|
317 | pthread_attr_getstacksize - Get Thread Stack Size |
---|
318 | ------------------------------------------------- |
---|
319 | .. index:: pthread_attr_getstacksize |
---|
320 | .. index:: get thread stack size |
---|
321 | |
---|
322 | **CALLING SEQUENCE:** |
---|
323 | |
---|
324 | .. code:: c |
---|
325 | |
---|
326 | #include <pthread.h> |
---|
327 | int pthread_attr_getstacksize( |
---|
328 | const pthread_attr_t \*attr, |
---|
329 | size_t \*stacksize |
---|
330 | ); |
---|
331 | |
---|
332 | **STATUS CODES:** |
---|
333 | |
---|
334 | *EINVAL* |
---|
335 | The attribute pointer argument is invalid. |
---|
336 | |
---|
337 | *EINVAL* |
---|
338 | The attribute set is not initialized. |
---|
339 | |
---|
340 | *EINVAL* |
---|
341 | The stacksize pointer argument is invalid. |
---|
342 | |
---|
343 | **DESCRIPTION:** |
---|
344 | |
---|
345 | The ``pthread_attr_getstacksize`` routine is used to obtain the``stacksize`` attribute in the ``attr`` thread attribute |
---|
346 | object. |
---|
347 | |
---|
348 | **NOTES:** |
---|
349 | |
---|
350 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_ATTR_STACKSIZE`` to indicate that this |
---|
351 | routine is supported. |
---|
352 | |
---|
353 | pthread_attr_setstackaddr - Set Thread Stack Address |
---|
354 | ---------------------------------------------------- |
---|
355 | .. index:: pthread_attr_setstackaddr |
---|
356 | .. index:: set thread stack address |
---|
357 | |
---|
358 | **CALLING SEQUENCE:** |
---|
359 | |
---|
360 | .. code:: c |
---|
361 | |
---|
362 | #include <pthread.h> |
---|
363 | int pthread_attr_setstackaddr( |
---|
364 | pthread_attr_t \*attr, |
---|
365 | void \*stackaddr |
---|
366 | ); |
---|
367 | |
---|
368 | **STATUS CODES:** |
---|
369 | |
---|
370 | *EINVAL* |
---|
371 | The attribute pointer argument is invalid. |
---|
372 | |
---|
373 | *EINVAL* |
---|
374 | The attribute set is not initialized. |
---|
375 | |
---|
376 | **DESCRIPTION:** |
---|
377 | |
---|
378 | The ``pthread_attr_setstackaddr`` routine is used to set the``stackaddr`` attribute in the ``attr`` thread attribute |
---|
379 | object. |
---|
380 | |
---|
381 | **NOTES:** |
---|
382 | |
---|
383 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_ATTR_STACKADDR`` to indicate that this |
---|
384 | routine is supported. |
---|
385 | |
---|
386 | It is imperative to the proper operation of the system that |
---|
387 | each thread have sufficient stack space. |
---|
388 | |
---|
389 | pthread_attr_getstackaddr - Get Thread Stack Address |
---|
390 | ---------------------------------------------------- |
---|
391 | .. index:: pthread_attr_getstackaddr |
---|
392 | .. index:: get thread stack address |
---|
393 | |
---|
394 | **CALLING SEQUENCE:** |
---|
395 | |
---|
396 | .. code:: c |
---|
397 | |
---|
398 | #include <pthread.h> |
---|
399 | int pthread_attr_getstackaddr( |
---|
400 | const pthread_attr_t \*attr, |
---|
401 | void \**stackaddr |
---|
402 | ); |
---|
403 | |
---|
404 | **STATUS CODES:** |
---|
405 | |
---|
406 | *EINVAL* |
---|
407 | The attribute pointer argument is invalid. |
---|
408 | |
---|
409 | *EINVAL* |
---|
410 | The attribute set is not initialized. |
---|
411 | |
---|
412 | *EINVAL* |
---|
413 | The stackaddr pointer argument is invalid. |
---|
414 | |
---|
415 | **DESCRIPTION:** |
---|
416 | |
---|
417 | The ``pthread_attr_getstackaddr`` routine is used to obtain the``stackaddr`` attribute in the ``attr`` thread attribute |
---|
418 | object. |
---|
419 | |
---|
420 | **NOTES:** |
---|
421 | |
---|
422 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_ATTR_STACKADDR`` to indicate that this |
---|
423 | routine is supported. |
---|
424 | |
---|
425 | pthread_attr_setscope - Set Thread Scheduling Scope |
---|
426 | --------------------------------------------------- |
---|
427 | .. index:: pthread_attr_setscope |
---|
428 | .. index:: set thread scheduling scope |
---|
429 | |
---|
430 | **CALLING SEQUENCE:** |
---|
431 | |
---|
432 | .. code:: c |
---|
433 | |
---|
434 | #include <pthread.h> |
---|
435 | int pthread_attr_setscope( |
---|
436 | pthread_attr_t \*attr, |
---|
437 | int contentionscope |
---|
438 | ); |
---|
439 | |
---|
440 | **STATUS CODES:** |
---|
441 | |
---|
442 | *EINVAL* |
---|
443 | The attribute pointer argument is invalid. |
---|
444 | |
---|
445 | *EINVAL* |
---|
446 | The attribute set is not initialized. |
---|
447 | |
---|
448 | *EINVAL* |
---|
449 | The contention scope specified is not valid. |
---|
450 | |
---|
451 | *ENOTSUP* |
---|
452 | The contention scope specified (PTHREAD_SCOPE_SYSTEM) is not supported. |
---|
453 | |
---|
454 | **DESCRIPTION:** |
---|
455 | |
---|
456 | The ``pthread_attr_setscope`` routine is used to set the contention |
---|
457 | scope field in the thread attribute object ``attr`` to the value |
---|
458 | specified by ``contentionscope``. |
---|
459 | |
---|
460 | The ``contentionscope`` must be either ``PTHREAD_SCOPE_SYSTEM`` |
---|
461 | to indicate that the thread is to be within system scheduling contention |
---|
462 | or ``PTHREAD_SCOPE_PROCESS`` indicating that the thread is to be |
---|
463 | within the process scheduling contention scope. |
---|
464 | |
---|
465 | **NOTES:** |
---|
466 | |
---|
467 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
468 | family of routines to which this routine belongs is supported. |
---|
469 | |
---|
470 | pthread_attr_getscope - Get Thread Scheduling Scope |
---|
471 | --------------------------------------------------- |
---|
472 | .. index:: pthread_attr_getscope |
---|
473 | .. index:: get thread scheduling scope |
---|
474 | |
---|
475 | **CALLING SEQUENCE:** |
---|
476 | |
---|
477 | .. code:: c |
---|
478 | |
---|
479 | #include <pthread.h> |
---|
480 | int pthread_attr_getscope( |
---|
481 | const pthread_attr_t \*attr, |
---|
482 | int \*contentionscope |
---|
483 | ); |
---|
484 | |
---|
485 | **STATUS CODES:** |
---|
486 | |
---|
487 | *EINVAL* |
---|
488 | The attribute pointer argument is invalid. |
---|
489 | |
---|
490 | *EINVAL* |
---|
491 | The attribute set is not initialized. |
---|
492 | |
---|
493 | *EINVAL* |
---|
494 | The contentionscope pointer argument is invalid. |
---|
495 | |
---|
496 | **DESCRIPTION:** |
---|
497 | |
---|
498 | The ``pthread_attr_getscope`` routine is used to obtain the |
---|
499 | value of the contention scope field in the thread attributes |
---|
500 | object ``attr``. The current value is returned in``contentionscope``. |
---|
501 | |
---|
502 | **NOTES:** |
---|
503 | |
---|
504 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
505 | family of routines to which this routine belongs is supported. |
---|
506 | |
---|
507 | pthread_attr_setinheritsched - Set Inherit Scheduler Flag |
---|
508 | --------------------------------------------------------- |
---|
509 | .. index:: pthread_attr_setinheritsched |
---|
510 | .. index:: set inherit scheduler flag |
---|
511 | |
---|
512 | **CALLING SEQUENCE:** |
---|
513 | |
---|
514 | .. code:: c |
---|
515 | |
---|
516 | #include <pthread.h> |
---|
517 | int pthread_attr_setinheritsched( |
---|
518 | pthread_attr_t \*attr, |
---|
519 | int inheritsched |
---|
520 | ); |
---|
521 | |
---|
522 | **STATUS CODES:** |
---|
523 | |
---|
524 | *EINVAL* |
---|
525 | The attribute pointer argument is invalid. |
---|
526 | |
---|
527 | *EINVAL* |
---|
528 | The attribute set is not initialized. |
---|
529 | |
---|
530 | *EINVAL* |
---|
531 | The specified scheduler inheritance argument is invalid. |
---|
532 | |
---|
533 | **DESCRIPTION:** |
---|
534 | |
---|
535 | The ``pthread_attr_setinheritsched`` routine is used to set the |
---|
536 | inherit scheduler field in the thread attribute object ``attr`` to |
---|
537 | the value specified by ``inheritsched``. |
---|
538 | |
---|
539 | The ``contentionscope`` must be either ``PTHREAD_INHERIT_SCHED`` |
---|
540 | to indicate that the thread is to inherit the scheduling policy |
---|
541 | and parameters fromthe creating thread, or ``PTHREAD_EXPLICIT_SCHED`` |
---|
542 | to indicate that the scheduling policy and parameters for this thread |
---|
543 | are to be set from the corresponding values in the attributes object. |
---|
544 | If ``contentionscope`` is ``PTHREAD_INHERIT_SCHED``, then the |
---|
545 | scheduling attributes in the ``attr`` structure will be ignored |
---|
546 | at thread creation time. |
---|
547 | |
---|
548 | **NOTES:** |
---|
549 | |
---|
550 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
551 | family of routines to which this routine belongs is supported. |
---|
552 | |
---|
553 | pthread_attr_getinheritsched - Get Inherit Scheduler Flag |
---|
554 | --------------------------------------------------------- |
---|
555 | .. index:: pthread_attr_getinheritsched |
---|
556 | .. index:: get inherit scheduler flag |
---|
557 | |
---|
558 | **CALLING SEQUENCE:** |
---|
559 | |
---|
560 | .. code:: c |
---|
561 | |
---|
562 | #include <pthread.h> |
---|
563 | int pthread_attr_getinheritsched( |
---|
564 | const pthread_attr_t \*attr, |
---|
565 | int \*inheritsched |
---|
566 | ); |
---|
567 | |
---|
568 | **STATUS CODES:** |
---|
569 | |
---|
570 | *EINVAL* |
---|
571 | The attribute pointer argument is invalid. |
---|
572 | |
---|
573 | *EINVAL* |
---|
574 | The attribute set is not initialized. |
---|
575 | |
---|
576 | *EINVAL* |
---|
577 | The inheritsched pointer argument is invalid. |
---|
578 | |
---|
579 | **DESCRIPTION:** |
---|
580 | |
---|
581 | The ``pthread_attr_getinheritsched`` routine is used to |
---|
582 | object the current value of the inherit scheduler field in |
---|
583 | the thread attribute object ``attr``. |
---|
584 | |
---|
585 | **NOTES:** |
---|
586 | |
---|
587 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
588 | family of routines to which this routine belongs is supported. |
---|
589 | |
---|
590 | pthread_attr_setschedpolicy - Set Scheduling Policy |
---|
591 | --------------------------------------------------- |
---|
592 | .. index:: pthread_attr_setschedpolicy |
---|
593 | .. index:: set scheduling policy |
---|
594 | |
---|
595 | **CALLING SEQUENCE:** |
---|
596 | |
---|
597 | .. code:: c |
---|
598 | |
---|
599 | #include <pthread.h> |
---|
600 | int pthread_attr_setschedpolicy( |
---|
601 | pthread_attr_t \*attr, |
---|
602 | int policy |
---|
603 | ); |
---|
604 | |
---|
605 | **STATUS CODES:** |
---|
606 | |
---|
607 | *EINVAL* |
---|
608 | The attribute pointer argument is invalid. |
---|
609 | |
---|
610 | *EINVAL* |
---|
611 | The attribute set is not initialized. |
---|
612 | |
---|
613 | *ENOTSUP* |
---|
614 | The specified scheduler policy argument is invalid. |
---|
615 | |
---|
616 | **DESCRIPTION:** |
---|
617 | |
---|
618 | The ``pthread_attr_setschedpolicy`` routine is used to set the |
---|
619 | scheduler policy field in the thread attribute object ``attr`` to |
---|
620 | the value specified by ``policy``. |
---|
621 | |
---|
622 | Scheduling policies may be one of the following: |
---|
623 | |
---|
624 | - ``SCHED_DEFAULT`` |
---|
625 | |
---|
626 | - ``SCHED_FIFO`` |
---|
627 | |
---|
628 | - ``SCHED_RR`` |
---|
629 | |
---|
630 | - ``SCHED_SPORADIC`` |
---|
631 | |
---|
632 | - ``SCHED_OTHER`` |
---|
633 | |
---|
634 | The precise meaning of each of these is discussed elsewhere in this |
---|
635 | manual. |
---|
636 | |
---|
637 | **NOTES:** |
---|
638 | |
---|
639 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
640 | family of routines to which this routine belongs is supported. |
---|
641 | |
---|
642 | pthread_attr_getschedpolicy - Get Scheduling Policy |
---|
643 | --------------------------------------------------- |
---|
644 | .. index:: pthread_attr_getschedpolicy |
---|
645 | .. index:: get scheduling policy |
---|
646 | |
---|
647 | **CALLING SEQUENCE:** |
---|
648 | |
---|
649 | .. code:: c |
---|
650 | |
---|
651 | #include <pthread.h> |
---|
652 | int pthread_attr_getschedpolicy( |
---|
653 | const pthread_attr_t \*attr, |
---|
654 | int \*policy |
---|
655 | ); |
---|
656 | |
---|
657 | **STATUS CODES:** |
---|
658 | |
---|
659 | *EINVAL* |
---|
660 | The attribute pointer argument is invalid. |
---|
661 | |
---|
662 | *EINVAL* |
---|
663 | The attribute set is not initialized. |
---|
664 | |
---|
665 | *EINVAL* |
---|
666 | The specified scheduler policy argument pointer is invalid. |
---|
667 | |
---|
668 | **DESCRIPTION:** |
---|
669 | |
---|
670 | The ``pthread_attr_getschedpolicy`` routine is used to obtain the |
---|
671 | scheduler policy field from the thread attribute object ``attr``. |
---|
672 | The value of this field is returned in ``policy``. |
---|
673 | |
---|
674 | **NOTES:** |
---|
675 | |
---|
676 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
677 | family of routines to which this routine belongs is supported. |
---|
678 | |
---|
679 | pthread_attr_setschedparam - Set Scheduling Parameters |
---|
680 | ------------------------------------------------------ |
---|
681 | .. index:: pthread_attr_setschedparam |
---|
682 | .. index:: set scheduling parameters |
---|
683 | |
---|
684 | **CALLING SEQUENCE:** |
---|
685 | |
---|
686 | .. code:: c |
---|
687 | |
---|
688 | #include <pthread.h> |
---|
689 | int pthread_attr_setschedparam( |
---|
690 | pthread_attr_t \*attr, |
---|
691 | const struct sched_param param |
---|
692 | ); |
---|
693 | |
---|
694 | **STATUS CODES:** |
---|
695 | |
---|
696 | *EINVAL* |
---|
697 | The attribute pointer argument is invalid. |
---|
698 | |
---|
699 | *EINVAL* |
---|
700 | The attribute set is not initialized. |
---|
701 | |
---|
702 | *EINVAL* |
---|
703 | The specified scheduler parameter argument is invalid. |
---|
704 | |
---|
705 | **DESCRIPTION:** |
---|
706 | |
---|
707 | The ``pthread_attr_setschedparam`` routine is used to set the |
---|
708 | scheduler parameters field in the thread attribute object ``attr`` to |
---|
709 | the value specified by ``param``. |
---|
710 | |
---|
711 | **NOTES:** |
---|
712 | |
---|
713 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
714 | family of routines to which this routine belongs is supported. |
---|
715 | |
---|
716 | pthread_attr_getschedparam - Get Scheduling Parameters |
---|
717 | ------------------------------------------------------ |
---|
718 | .. index:: pthread_attr_getschedparam |
---|
719 | .. index:: get scheduling parameters |
---|
720 | |
---|
721 | **CALLING SEQUENCE:** |
---|
722 | |
---|
723 | .. code:: c |
---|
724 | |
---|
725 | #include <pthread.h> |
---|
726 | int pthread_attr_getschedparam( |
---|
727 | const pthread_attr_t \*attr, |
---|
728 | struct sched_param \*param |
---|
729 | ); |
---|
730 | |
---|
731 | **STATUS CODES:** |
---|
732 | |
---|
733 | *EINVAL* |
---|
734 | The attribute pointer argument is invalid. |
---|
735 | |
---|
736 | *EINVAL* |
---|
737 | The attribute set is not initialized. |
---|
738 | |
---|
739 | *EINVAL* |
---|
740 | The specified scheduler parameter argument pointer is invalid. |
---|
741 | |
---|
742 | **DESCRIPTION:** |
---|
743 | |
---|
744 | The ``pthread_attr_getschedparam`` routine is used to obtain the |
---|
745 | scheduler parameters field from the thread attribute object ``attr``. |
---|
746 | The value of this field is returned in ``param``. |
---|
747 | |
---|
748 | **NOTES:** |
---|
749 | |
---|
750 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
751 | family of routines to which this routine belongs is supported. |
---|
752 | |
---|
753 | pthread_attr_getaffinity_np - Get Thread Affinity Attribute |
---|
754 | ----------------------------------------------------------- |
---|
755 | |
---|
756 | **CALLING SEQUENCE:** |
---|
757 | |
---|
758 | .. code:: c |
---|
759 | |
---|
760 | #define _GNU_SOURCE |
---|
761 | #include <pthread.h> |
---|
762 | int pthread_attr_getaffinity_np( |
---|
763 | const pthread_attr_t \*attr, |
---|
764 | size_t cpusetsize, |
---|
765 | cpu_set_t \*cpuset |
---|
766 | ); |
---|
767 | |
---|
768 | **STATUS CODES:** |
---|
769 | |
---|
770 | *EFAULT* |
---|
771 | The attribute pointer argument is invalid. |
---|
772 | |
---|
773 | *EFAULT* |
---|
774 | The cpuset pointer argument is invalid. |
---|
775 | |
---|
776 | *EINVAL* |
---|
777 | The ``cpusetsize`` does not match the value of ``affinitysetsize`` |
---|
778 | field in the thread attribute object. |
---|
779 | |
---|
780 | **DESCRIPTION:** |
---|
781 | |
---|
782 | The ``pthread_attr_getaffinity_np`` routine is used to obtain the``affinityset`` field from the thread attribute object ``attr``. |
---|
783 | The value of this field is returned in ``cpuset``. |
---|
784 | |
---|
785 | **NOTES:** |
---|
786 | |
---|
787 | NONE |
---|
788 | |
---|
789 | pthread_attr_setaffinity_np - Set Thread Affinity Attribute |
---|
790 | ----------------------------------------------------------- |
---|
791 | |
---|
792 | **CALLING SEQUENCE:** |
---|
793 | |
---|
794 | .. code:: c |
---|
795 | |
---|
796 | #define _GNU_SOURCE |
---|
797 | #include <pthread.h> |
---|
798 | int pthread_attr_setaffinity_np( |
---|
799 | pthread_attr_t \*attr, |
---|
800 | size_t cpusetsize, |
---|
801 | const cpu_set_t \*cpuset |
---|
802 | ); |
---|
803 | |
---|
804 | **STATUS CODES:** |
---|
805 | |
---|
806 | *EFAULT* |
---|
807 | The attribute pointer argument is invalid. |
---|
808 | |
---|
809 | *EFAULT* |
---|
810 | The cpuset pointer argument is invalid. |
---|
811 | |
---|
812 | *EINVAL* |
---|
813 | The ``cpusetsize`` does not match the value of ``affinitysetsize`` |
---|
814 | field in the thread attribute object. |
---|
815 | |
---|
816 | *EINVAL* |
---|
817 | The ``cpuset`` did not select a valid cpu. |
---|
818 | |
---|
819 | *EINVAL* |
---|
820 | The ``cpuset`` selected a cpu that was invalid. |
---|
821 | |
---|
822 | **DESCRIPTION:** |
---|
823 | |
---|
824 | The ``pthread_attr_setaffinity_np`` routine is used to set the``affinityset`` field in the thread attribute object ``attr``. |
---|
825 | The value of this field is returned in ``cpuset``. |
---|
826 | |
---|
827 | **NOTES:** |
---|
828 | |
---|
829 | NONE |
---|
830 | |
---|
831 | pthread_create - Create a Thread |
---|
832 | -------------------------------- |
---|
833 | .. index:: pthread_create |
---|
834 | .. index:: create a thread |
---|
835 | |
---|
836 | **CALLING SEQUENCE:** |
---|
837 | |
---|
838 | .. code:: c |
---|
839 | |
---|
840 | #include <pthread.h> |
---|
841 | int pthread_create( |
---|
842 | pthread_t \*thread, |
---|
843 | const pthread_attr_t \*attr, |
---|
844 | void (\*start_routine)( void \*), |
---|
845 | void \*arg |
---|
846 | ); |
---|
847 | |
---|
848 | **STATUS CODES:** |
---|
849 | |
---|
850 | *EINVAL* |
---|
851 | The attribute set is not initialized. |
---|
852 | |
---|
853 | *EINVAL* |
---|
854 | The user specified a stack address and the size of the area was not |
---|
855 | large enough to meet this processorâs minimum stack requirements. |
---|
856 | |
---|
857 | *EINVAL* |
---|
858 | The specified scheduler inheritance policy was invalid. |
---|
859 | |
---|
860 | *ENOTSUP* |
---|
861 | The specified contention scope was PTHREAD_SCOPE_PROCESS. |
---|
862 | |
---|
863 | *EINVAL* |
---|
864 | The specified thread priority was invalid. |
---|
865 | |
---|
866 | *EINVAL* |
---|
867 | The specified scheduling policy was invalid. |
---|
868 | |
---|
869 | *EINVAL* |
---|
870 | The scheduling policy was SCHED_SPORADIC and the specified replenishment |
---|
871 | period is less than the initial budget. |
---|
872 | |
---|
873 | *EINVAL* |
---|
874 | The scheduling policy was SCHED_SPORADIC and the specified low priority |
---|
875 | is invalid. |
---|
876 | |
---|
877 | *EAGAIN* |
---|
878 | The system lacked the necessary resources to create another thread, or the |
---|
879 | self imposed limit on the total number of threads in a process |
---|
880 | PTHREAD_THREAD_MAX would be exceeded. |
---|
881 | |
---|
882 | *EINVAL* |
---|
883 | Invalid argument passed. |
---|
884 | |
---|
885 | **DESCRIPTION:** |
---|
886 | |
---|
887 | The ``pthread_create`` routine is used to create a new thread with |
---|
888 | the attributes specified by ``attr``. If the ``attr`` argument |
---|
889 | is ``NULL``, then the default attribute set will be used. Modification |
---|
890 | of the contents of ``attr`` after this thread is created does not |
---|
891 | have an impact on this thread. |
---|
892 | |
---|
893 | The thread begins execution at the address specified by ``start_routine`` |
---|
894 | with ``arg`` as its only argument. If ``start_routine`` returns, |
---|
895 | then it is functionally equivalent to the thread executing the``pthread_exit`` service. |
---|
896 | |
---|
897 | Upon successful completion, the ID of the created thread is returned in the``thread`` argument. |
---|
898 | |
---|
899 | **NOTES:** |
---|
900 | |
---|
901 | There is no concept of a single main thread in RTEMS as there is in |
---|
902 | a tradition UNIX system. POSIX requires that the implicit return of |
---|
903 | the main thread results in the same effects as if there were a call |
---|
904 | to ``exit``. This does not occur in RTEMS. |
---|
905 | |
---|
906 | The signal mask of the newly created thread is inherited from its |
---|
907 | creator and the set of pending signals for this thread is empty. |
---|
908 | |
---|
909 | pthread_exit - Terminate the Current Thread |
---|
910 | ------------------------------------------- |
---|
911 | .. index:: pthread_exit |
---|
912 | .. index:: terminate the current thread |
---|
913 | |
---|
914 | **CALLING SEQUENCE:** |
---|
915 | |
---|
916 | .. code:: c |
---|
917 | |
---|
918 | #include <pthread.h> |
---|
919 | void pthread_exit( |
---|
920 | void \*status |
---|
921 | ); |
---|
922 | |
---|
923 | **STATUS CODES:** |
---|
924 | |
---|
925 | *NONE* |
---|
926 | |
---|
927 | **DESCRIPTION:** |
---|
928 | |
---|
929 | The ``pthread_exit`` routine is used to terminate the calling thread. |
---|
930 | The ``status`` is made available to any successful join with the |
---|
931 | terminating thread. |
---|
932 | |
---|
933 | When a thread returns from its start routine, it results in an |
---|
934 | implicit call to the ``pthread_exit`` routine with the return |
---|
935 | value of the function serving as the argument to ``pthread_exit``. |
---|
936 | |
---|
937 | **NOTES:** |
---|
938 | |
---|
939 | Any cancellation cleanup handlers that hace been pushed and not yet popped |
---|
940 | shall be popped in reverse of the order that they were pushed. After |
---|
941 | all cancellation cleanup handlers have been executed, if the |
---|
942 | thread has any thread-specific data, destructors for that data will |
---|
943 | be invoked. |
---|
944 | |
---|
945 | Thread termination does not release or free any application visible |
---|
946 | resources including byt not limited to mutexes, file descriptors, allocated |
---|
947 | memory, etc.. Similarly, exitting a thread does not result in any |
---|
948 | process-oriented cleanup activity. |
---|
949 | |
---|
950 | There is no concept of a single main thread in RTEMS as there is in |
---|
951 | a tradition UNIX system. POSIX requires that the implicit return of |
---|
952 | the main thread results in the same effects as if there were a call |
---|
953 | to ``exit``. This does not occur in RTEMS. |
---|
954 | |
---|
955 | All access to any automatic variables allocated by the threads is lost |
---|
956 | when the thread exits. Thus references (i.e. pointers) to local variables |
---|
957 | of a thread should not be used in a global manner without care. As |
---|
958 | a specific example, a pointer to a local variable should NOT be used |
---|
959 | as the return value. |
---|
960 | |
---|
961 | pthread_detach - Detach a Thread |
---|
962 | -------------------------------- |
---|
963 | .. index:: pthread_detach |
---|
964 | .. index:: detach a thread |
---|
965 | |
---|
966 | **CALLING SEQUENCE:** |
---|
967 | |
---|
968 | .. code:: c |
---|
969 | |
---|
970 | #include <pthread.h> |
---|
971 | int pthread_detach( |
---|
972 | pthread_t thread |
---|
973 | ); |
---|
974 | |
---|
975 | **STATUS CODES:** |
---|
976 | |
---|
977 | *ESRCH* |
---|
978 | The thread specified is invalid. |
---|
979 | |
---|
980 | *EINVAL* |
---|
981 | The thread specified is not a joinable thread. |
---|
982 | |
---|
983 | **DESCRIPTION:** |
---|
984 | |
---|
985 | The ``pthread_detach`` routine is used to to indicate that storage |
---|
986 | for ``thread`` can be reclaimed when the thread terminates without |
---|
987 | another thread joinging with it. |
---|
988 | |
---|
989 | **NOTES:** |
---|
990 | |
---|
991 | If any threads have previously joined with the specified thread, then they |
---|
992 | will remain joined with that thread. Any subsequent calls to``pthread_join`` on the specified thread will fail. |
---|
993 | |
---|
994 | .. COMMENT: pthread_getattr_np |
---|
995 | |
---|
996 | pthread_getattr_np - Get Thread Attributes |
---|
997 | ------------------------------------------ |
---|
998 | .. index:: pthread_getattr_np |
---|
999 | .. index:: get thread attributes |
---|
1000 | |
---|
1001 | **CALLING SEQUENCE:** |
---|
1002 | |
---|
1003 | .. code:: c |
---|
1004 | |
---|
1005 | #define _GNU_SOURCE |
---|
1006 | #include <pthread.h> |
---|
1007 | int pthread_getattr_np( |
---|
1008 | pthread_t thread, |
---|
1009 | pthread_attr_t \*attr |
---|
1010 | ); |
---|
1011 | |
---|
1012 | **STATUS CODES:** |
---|
1013 | |
---|
1014 | *ESRCH* |
---|
1015 | The thread specified is invalid. |
---|
1016 | |
---|
1017 | *EINVAL* |
---|
1018 | The attribute pointer argument is invalid. |
---|
1019 | |
---|
1020 | **DESCRIPTION:** |
---|
1021 | |
---|
1022 | The ``pthread_getattr_np`` routine is used to obtain the |
---|
1023 | attributes associated with ``thread``. |
---|
1024 | |
---|
1025 | **NOTES:** |
---|
1026 | |
---|
1027 | Modification of the execution modes and priority through the Classic API |
---|
1028 | may result in a combination that is not representable in the POSIX API. |
---|
1029 | |
---|
1030 | pthread_join - Wait for Thread Termination |
---|
1031 | ------------------------------------------ |
---|
1032 | .. index:: pthread_join |
---|
1033 | .. index:: wait for thread termination |
---|
1034 | |
---|
1035 | **CALLING SEQUENCE:** |
---|
1036 | |
---|
1037 | .. code:: c |
---|
1038 | |
---|
1039 | #include <pthread.h> |
---|
1040 | int pthread_join( |
---|
1041 | pthread_t thread, |
---|
1042 | void \**value_ptr |
---|
1043 | ); |
---|
1044 | |
---|
1045 | **STATUS CODES:** |
---|
1046 | |
---|
1047 | *ESRCH* |
---|
1048 | The thread specified is invalid. |
---|
1049 | |
---|
1050 | *EINVAL* |
---|
1051 | The thread specified is not a joinable thread. |
---|
1052 | |
---|
1053 | *EDEADLK* |
---|
1054 | A deadlock was detected or thread is the calling thread. |
---|
1055 | |
---|
1056 | **DESCRIPTION:** |
---|
1057 | |
---|
1058 | The ``pthread_join`` routine suspends execution of the calling thread |
---|
1059 | until ``thread`` terminates. If ``thread`` has already terminated, |
---|
1060 | then this routine returns immediately. The value returned by ``thread`` |
---|
1061 | (i.e. passed to ``pthread_exit`` is returned in ``value_ptr``. |
---|
1062 | |
---|
1063 | When this routine returns, then ``thread`` has been terminated. |
---|
1064 | |
---|
1065 | **NOTES:** |
---|
1066 | |
---|
1067 | The results of multiple simultaneous joins on the same thread is undefined. |
---|
1068 | |
---|
1069 | If any threads have previously joined with the specified thread, then they |
---|
1070 | will remain joined with that thread. Any subsequent calls to``pthread_join`` on the specified thread will fail. |
---|
1071 | |
---|
1072 | If value_ptr is NULL, then no value is returned. |
---|
1073 | |
---|
1074 | pthread_self - Get Thread ID |
---|
1075 | ---------------------------- |
---|
1076 | .. index:: pthread_self |
---|
1077 | .. index:: get thread id |
---|
1078 | |
---|
1079 | **CALLING SEQUENCE:** |
---|
1080 | |
---|
1081 | .. code:: c |
---|
1082 | |
---|
1083 | #include <pthread.h> |
---|
1084 | pthread_t pthread_self( void ); |
---|
1085 | |
---|
1086 | **STATUS CODES:** |
---|
1087 | |
---|
1088 | The value returned is the ID of the calling thread. |
---|
1089 | |
---|
1090 | **DESCRIPTION:** |
---|
1091 | |
---|
1092 | This routine returns the ID of the calling thread. |
---|
1093 | |
---|
1094 | **NOTES:** |
---|
1095 | |
---|
1096 | NONE |
---|
1097 | |
---|
1098 | pthread_equal - Compare Thread IDs |
---|
1099 | ---------------------------------- |
---|
1100 | .. index:: pthread_equal |
---|
1101 | .. index:: compare thread ids |
---|
1102 | |
---|
1103 | **CALLING SEQUENCE:** |
---|
1104 | |
---|
1105 | .. code:: c |
---|
1106 | |
---|
1107 | #include <pthread.h> |
---|
1108 | int pthread_equal( |
---|
1109 | pthread_t t1, |
---|
1110 | pthread_t t2 |
---|
1111 | ); |
---|
1112 | |
---|
1113 | **STATUS CODES:** |
---|
1114 | |
---|
1115 | *zero* |
---|
1116 | The thread ids are not equal. |
---|
1117 | |
---|
1118 | *non-zero* |
---|
1119 | The thread ids are equal. |
---|
1120 | |
---|
1121 | **DESCRIPTION:** |
---|
1122 | |
---|
1123 | The ``pthread_equal`` routine is used to compare two thread |
---|
1124 | IDs and determine if they are equal. |
---|
1125 | |
---|
1126 | **NOTES:** |
---|
1127 | |
---|
1128 | The behavior is undefined if the thread IDs are not valid. |
---|
1129 | |
---|
1130 | pthread_once - Dynamic Package Initialization |
---|
1131 | --------------------------------------------- |
---|
1132 | .. index:: pthread_once |
---|
1133 | .. index:: dynamic package initialization |
---|
1134 | |
---|
1135 | **CALLING SEQUENCE:** |
---|
1136 | |
---|
1137 | .. code:: c |
---|
1138 | |
---|
1139 | #include <pthread.h> |
---|
1140 | pthread_once_t once_control = PTHREAD_ONCE_INIT; |
---|
1141 | int pthread_once( |
---|
1142 | pthread_once_t \*once_control, |
---|
1143 | void (\*init_routine)(void) |
---|
1144 | ); |
---|
1145 | |
---|
1146 | **STATUS CODES:** |
---|
1147 | |
---|
1148 | NONE |
---|
1149 | |
---|
1150 | **DESCRIPTION:** |
---|
1151 | |
---|
1152 | The ``pthread_once`` routine is used to provide controlled initialization |
---|
1153 | of variables. The first call to ``pthread_once`` by any thread with the |
---|
1154 | same ``once_control`` will result in the ``init_routine`` being |
---|
1155 | invoked with no arguments. Subsequent calls to ``pthread_once`` with |
---|
1156 | the same ``once_control`` will have no effect. |
---|
1157 | |
---|
1158 | The ``init_routine`` is guaranteed to have run to completion when |
---|
1159 | this routine returns to the caller. |
---|
1160 | |
---|
1161 | **NOTES:** |
---|
1162 | |
---|
1163 | The behavior of ``pthread_once`` is undefined if ``once_control`` |
---|
1164 | is automatic storage (i.e. on a task stack) or is not initialized using``PTHREAD_ONCE_INIT``. |
---|
1165 | |
---|
1166 | pthread_setschedparam - Set Thread Scheduling Parameters |
---|
1167 | -------------------------------------------------------- |
---|
1168 | .. index:: pthread_setschedparam |
---|
1169 | .. index:: set thread scheduling parameters |
---|
1170 | |
---|
1171 | **CALLING SEQUENCE:** |
---|
1172 | |
---|
1173 | .. code:: c |
---|
1174 | |
---|
1175 | #include <pthread.h> |
---|
1176 | int pthread_setschedparam( |
---|
1177 | pthread_t thread, |
---|
1178 | int policy, |
---|
1179 | struct sched_param \*param |
---|
1180 | ); |
---|
1181 | |
---|
1182 | **STATUS CODES:** |
---|
1183 | |
---|
1184 | *EINVAL* |
---|
1185 | The scheduling parameters indicated by the parameter param is invalid. |
---|
1186 | |
---|
1187 | *EINVAL* |
---|
1188 | The value specified by policy is invalid. |
---|
1189 | |
---|
1190 | *EINVAL* |
---|
1191 | The scheduling policy was SCHED_SPORADIC and the specified replenishment |
---|
1192 | period is less than the initial budget. |
---|
1193 | |
---|
1194 | *EINVAL* |
---|
1195 | The scheduling policy was SCHED_SPORADIC and the specified low priority |
---|
1196 | is invalid. |
---|
1197 | |
---|
1198 | *ESRCH* |
---|
1199 | The thread indicated was invalid. |
---|
1200 | |
---|
1201 | **DESCRIPTION:** |
---|
1202 | |
---|
1203 | The ``pthread_setschedparam`` routine is used to set the |
---|
1204 | scheduler parameters currently associated with the thread specified |
---|
1205 | by ``thread`` to the policy specified by ``policy``. The |
---|
1206 | contents of ``param`` are interpreted based upon the ``policy`` |
---|
1207 | argument. |
---|
1208 | |
---|
1209 | **NOTES:** |
---|
1210 | |
---|
1211 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
1212 | family of routines to which this routine belongs is supported. |
---|
1213 | |
---|
1214 | pthread_getschedparam - Get Thread Scheduling Parameters |
---|
1215 | -------------------------------------------------------- |
---|
1216 | .. index:: pthread_getschedparam |
---|
1217 | .. index:: get thread scheduling parameters |
---|
1218 | |
---|
1219 | **CALLING SEQUENCE:** |
---|
1220 | |
---|
1221 | .. code:: c |
---|
1222 | |
---|
1223 | #include <pthread.h> |
---|
1224 | int pthread_getschedparam( |
---|
1225 | pthread_t thread, |
---|
1226 | int \*policy, |
---|
1227 | struct sched_param \*param |
---|
1228 | ); |
---|
1229 | |
---|
1230 | **STATUS CODES:** |
---|
1231 | |
---|
1232 | *EINVAL* |
---|
1233 | The policy pointer argument is invalid. |
---|
1234 | |
---|
1235 | *EINVAL* |
---|
1236 | The scheduling parameters pointer argument is invalid. |
---|
1237 | |
---|
1238 | *ESRCH* |
---|
1239 | The thread indicated by the parameter thread is invalid. |
---|
1240 | |
---|
1241 | **DESCRIPTION:** |
---|
1242 | |
---|
1243 | The ``pthread_getschedparam`` routine is used to obtain the |
---|
1244 | scheduler policy and parameters associated with ``thread``. |
---|
1245 | The current policy and associated parameters values returned in``policy`` and ``param``, respectively. |
---|
1246 | |
---|
1247 | **NOTES:** |
---|
1248 | |
---|
1249 | As required by POSIX, RTEMS defines the feature symbol``_POSIX_THREAD_PRIORITY_SCHEDULING`` to indicate that the |
---|
1250 | family of routines to which this routine belongs is supported. |
---|
1251 | |
---|
1252 | .. COMMENT: pthread_getaffinity_np |
---|
1253 | |
---|
1254 | pthread_getaffinity_np - Get Thread Affinity |
---|
1255 | -------------------------------------------- |
---|
1256 | |
---|
1257 | **CALLING SEQUENCE:** |
---|
1258 | |
---|
1259 | .. code:: c |
---|
1260 | |
---|
1261 | #define _GNU_SOURCE |
---|
1262 | #include <pthread.h> |
---|
1263 | int pthread_getaffinity_np( |
---|
1264 | const pthread_t id, |
---|
1265 | size_t cpusetsize, |
---|
1266 | cpu_set_t \*cpuset |
---|
1267 | ); |
---|
1268 | |
---|
1269 | **STATUS CODES:** |
---|
1270 | |
---|
1271 | *EFAULT* |
---|
1272 | The cpuset pointer argument is invalid. |
---|
1273 | |
---|
1274 | *EINVAL* |
---|
1275 | The ``cpusetsize`` does not match the value of ``affinitysetsize`` |
---|
1276 | field in the thread attribute object. |
---|
1277 | |
---|
1278 | **DESCRIPTION:** |
---|
1279 | |
---|
1280 | The ``pthread_getaffinity_np`` routine is used to obtain the``affinity.set`` field from the thread control object associated |
---|
1281 | with the ``id``. The value of this field is returned in ``cpuset``. |
---|
1282 | |
---|
1283 | **NOTES:** |
---|
1284 | |
---|
1285 | NONE |
---|
1286 | |
---|
1287 | .. COMMENT: pthread_setaffinity_np |
---|
1288 | |
---|
1289 | pthread_setaffinity_np - Set Thread Affinity |
---|
1290 | -------------------------------------------- |
---|
1291 | |
---|
1292 | **CALLING SEQUENCE:** |
---|
1293 | |
---|
1294 | .. code:: c |
---|
1295 | |
---|
1296 | #define _GNU_SOURCE |
---|
1297 | #include <pthread.h> |
---|
1298 | int pthread_setaffinity_np( |
---|
1299 | pthread_t id, |
---|
1300 | size_t cpusetsize, |
---|
1301 | const cpu_set_t \*cpuset |
---|
1302 | ); |
---|
1303 | |
---|
1304 | **STATUS CODES:** |
---|
1305 | |
---|
1306 | *EFAULT* |
---|
1307 | The cpuset pointer argument is invalid. |
---|
1308 | |
---|
1309 | *EINVAL* |
---|
1310 | The ``cpusetsize`` does not match the value of ``affinitysetsize`` |
---|
1311 | field in the thread attribute object. |
---|
1312 | |
---|
1313 | *EINVAL* |
---|
1314 | The ``cpuset`` did not select a valid cpu. |
---|
1315 | |
---|
1316 | *EINVAL* |
---|
1317 | The ``cpuset`` selected a cpu that was invalid. |
---|
1318 | |
---|
1319 | **DESCRIPTION:** |
---|
1320 | |
---|
1321 | The ``pthread_setaffinity_np`` routine is used to set the``affinityset`` field of the thread object ``id``. |
---|
1322 | The value of this field is returned in ``cpuset`` |
---|
1323 | |
---|
1324 | **NOTES:** |
---|
1325 | |
---|
1326 | NONE |
---|
1327 | |
---|
1328 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
1329 | |
---|
1330 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
1331 | |
---|
1332 | .. COMMENT: All rights reserved. |
---|
1333 | |
---|