source: rtems/doc/posix_users/thread.t @ 8ea8326

4.104.114.84.95
Last change on this file since 8ea8326 was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

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