source: rtems/c/src/exec/posix/base/pthread.h @ 591d45e

4.104.114.84.95
Last change on this file since 591d45e was eb5a7e07, checked in by Joel Sherrill <joel.sherrill@…>, on 10/06/95 at 20:48:38

fixed missing CVS IDs

  • Property mode set to 100644
File size: 9.4 KB
Line 
1/*  pthread.h
2 *
3 *  $Id$
4 */
5
6#ifndef __PTHREAD_h
7#define __PTHREAD_h
8
9#include <rtems/posix/features.h>
10
11#if defined(_POSIX_THREADS)
12
13#include <sys/types.h>
14#include <time.h>
15#include <sys/sched.h>
16
17/*
18 *  3.1.3 Register Fork Handlers, P1003.1c/Draft 10, P1003.1c/Draft 10, p. 27
19 */
20
21int pthread_atfork(
22  void (*prepare)(void),
23  void (*parent)(void),
24  void (*child)(void)
25);
26
27/*
28 *  11.3.1 Mutex Initialization Attributes, P1003.1c/Draft 10, p. 81
29 */
30
31int pthread_mutexattr_init(
32  pthread_mutexattr_t *attr
33);
34
35int pthread_mutexattr_destroy(
36  pthread_mutexattr_t *attr
37);
38
39int pthread_mutexattr_getpshared(
40  const pthread_mutexattr_t *attr,
41  int                       *pshared
42);
43
44int pthread_mutexattr_setpshared(
45  pthread_mutexattr_t *attr,
46  int                  pshared
47);
48
49/*
50 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
51 */
52
53int pthread_mutex_init(
54  pthread_mutex_t           *mutex,
55  const pthread_mutexattr_t *attr
56);
57
58int pthread_mutex_destroy(
59  pthread_mutex_t           *mutex
60);
61
62/*
63 *  This is used to statically initialize a pthread_mutex_t. Example:
64 *
65 *  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
66 */
67
68#define PTHREAD_MUTEX_INITIALIZER  ((pthread_mutex_t) 0xFFFFFFFF)
69
70/*
71 *  11.3.3 Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
72 *       
73 *  NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29
74 */
75
76int pthread_mutex_lock(
77  pthread_mutex_t           *mutex
78);
79
80int pthread_mutex_trylock(
81  pthread_mutex_t           *mutex
82);
83
84int pthread_mutex_unlock(
85  pthread_mutex_t           *mutex
86);
87
88#if defined(_POSIX_TIMEOUTS)
89
90int pthread_mutex_timedlock(
91  pthread_mutex_t       *mutex,
92  const struct timespec *timeout
93);
94
95#endif /* _POSIX_TIMEOUTS */
96
97/*
98 *  11.4.1 Condition Variable Initialization Attributes,
99 *            P1003.1c/Draft 10, p. 96
100 */
101 
102int pthread_condattr_init(
103  pthread_condattr_t *attr
104);
105 
106int pthread_condattr_destroy(
107  pthread_condattr_t *attr
108);
109 
110int pthread_condattr_getpshared(
111  const pthread_condattr_t *attr,
112  int                      *pshared
113);
114 
115int pthread_condattr_setpshared(
116  pthread_condattr_t  *attr,
117  int                  pshared
118);
119 
120/*
121 *  11.4.2 Initializing and Destroying a Condition Variable,
122 *         P1003.1c/Draft 10, p. 87
123 */
124 
125int pthread_cond_init(
126  pthread_cond_t           *cond,
127  const pthread_condattr_t *attr
128);
129 
130int pthread_cond_destroy(
131  pthread_cond_t           *mutex
132);
133 
134/*
135 *  This is used to statically initialize a pthread_cond_t. Example:
136 *
137 *  pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
138 */
139 
140#define PTHREAD_COND_INITIALIZER  ((pthread_mutex_t) 0xFFFFFFFF)
141 
142/*
143 *  11.4.3 Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101
144 */
145 
146int pthread_cond_signal(
147  pthread_cond_t   *cond
148);
149 
150int pthread_cond_broadcast(
151  pthread_cond_t   *cond
152);
153 
154/*
155 *  11.4.4 Waiting on a Condition, P1003.1c/Draft 10, p. 105
156 */
157 
158int pthread_cond_wait(
159  pthread_cond_t     *cond,
160  pthread_mutex_t    *mutex
161);
162 
163int pthread_cond_timedwait(
164  pthread_cond_t        *cond,
165  pthread_mutex_t       *mutex,
166  const struct timespec *abstime
167);
168 
169#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
170
171/*
172 *  13.5.1 Thread Creation Scheduling Attributes, P1003.1c/Draft 10, p. 120
173 */
174
175int pthread_attr_setscope(
176  pthread_attr_t  *attr,
177  int              contentionscope
178);
179
180int pthread_attr_getscope(
181  const pthread_attr_t  *attr,
182  int                   *contentionscope
183);
184
185#define PTHREAD_INHERIT_SCHED  0      /* scheduling policy and associated */
186                                      /*   attributes are inherited from */
187                                      /*   the calling thread. */
188#define PTHREAD_EXPLICIT_SCHED 0      /* set from provided attribute object */
189
190int pthread_attr_setinheritsched(
191  pthread_attr_t  *attr,
192  int              inheritsched
193);
194
195int pthread_attr_getinheritsched(
196  const pthread_attr_t  *attr,
197  int                   *inheritsched
198);
199
200int pthread_attr_setschedpolicy(
201  pthread_attr_t  *attr,
202  int              policy
203);
204
205int pthread_attr_getschedpolicy(
206  const pthread_attr_t  *attr,
207  int                   *policy
208);
209
210#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
211
212int pthread_attr_setschedparam(
213  pthread_attr_t            *attr,
214  const struct sched_param   param
215);
216
217int pthread_attr_getschedparam(
218  const pthread_attr_t  *attr,
219  struct sched_param    *param
220);
221
222#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
223
224/*
225 *  13.5.2 Dynamic Thread Scheduling Parameters Access,
226 *         P1003.1c/Draft 10, p. 124
227 */
228
229int pthread_getschedparam(
230  pthread_t           thread,
231  int                *policy,
232  struct sched_param *param
233);
234
235int pthread_setschedparam(
236  pthread_t           thread,
237  int                 policy,
238  struct sched_param *param
239);
240
241#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
242
243#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
244
245/*
246 *  13.6.1 Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128
247 */
248 
249/*
250 *  Values for protocol.
251 */
252
253#define PTHREAD_PRIO_NONE    0
254#define PTHREAD_PRIO_INHERIT 1
255#define PTHREAD_PRIO_PROTECT 2
256
257int pthread_mutexattr_setprotocol(
258  pthread_mutexattr_t   *attr,
259  int                    protocol
260);
261
262int pthread_mutexattr_getprotocol(
263  const pthread_mutexattr_t   *attr,
264  int                         *protocol
265);
266
267int pthread_mutexattr_setprioceiling(
268  pthread_mutexattr_t   *attr,
269  int                    prioceiling
270);
271
272int pthread_mutexattr_getprioceiling(
273  const pthread_mutexattr_t   *attr,
274  int                         *prioceiling
275);
276
277#endif /* _POSIX_THREAD_PRIO_INHERIT || _POSIX_THREAD_PRIO_PROTECT */
278
279#if defined(_POSIX_THREAD_PRIO_PROTECT)
280
281/*
282 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
283 */
284
285int pthread_mutex_setprioceiling(
286  pthread_mutex_t   *mutex,
287  int                prioceiling,
288  int               *old_ceiling
289);
290 
291int pthread_mutex_getprioceiling(
292  pthread_mutex_t   *mutex,
293  int               *prioceiling
294);
295
296#endif /* _POSIX_THREAD_PRIO_PROTECT */
297
298/*
299 *  16.1.1 Thread Creation Attributes, P1003.1c/Draft 10, p, 140
300 */
301
302int pthread_attr_init(
303  pthread_attr_t  *attr
304);
305
306int pthread_attr_destroy(
307  pthread_attr_t  *attr
308);
309 
310int pthread_attr_getstacksize(
311  const pthread_attr_t  *attr,
312  size_t                *stacksize
313);
314 
315int pthread_attr_setstacksize(
316  pthread_attr_t  *attr,
317  size_t           stacksize
318);
319 
320int pthread_attr_getstackaddr(
321  const pthread_attr_t   *attr,
322  void                  **stackaddr
323);
324 
325int pthread_attr_setstackaddr(
326  pthread_attr_t  *attr,
327  void            *stackaddr
328);
329 
330int pthread_attr_getdetachstate(
331  const pthread_attr_t  *attr,
332  int                   *detachstate
333);
334 
335int pthread_attr_setdetachstate(
336  pthread_attr_t  *attr,
337  int              detachstate
338);
339
340/*
341 *  16.1.2 Thread Creation, P1003.1c/Draft 10, p. 144
342 */
343
344int pthread_create(
345  pthread_t             *thread,
346  const pthread_attr_t  *attr,
347  void                 (*start_routine)( void * ),
348  void                  *arg
349);
350
351/*
352 *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
353 */
354
355int pthread_join(
356  pthread_t   thread,
357  void      **value_ptr
358);
359
360/*
361 *  16.1.4 Detaching a Thread, P1003.1c/Draft 10, p. 149
362 */
363
364int pthread_detach(
365  pthread_t   thread
366);
367
368/*
369 * 16.1.6 Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX
370 */
371
372pthread_t pthread_self( void );
373
374/*
375 *  16.1.7 Compare Thread IDs, p1003.1c/Draft 10, p. 153
376 */
377
378int pthread_equal(
379  pthread_t  t1,
380  pthread_t  t2
381);
382
383/*
384 *  16.1.8 Dynamic Package Initialization
385 */
386
387/*
388 *  This is used to statically initialize a pthread_once_t. Example:
389 *
390 *  pthread_once_t once = PTHREAD_ONCE_INITIALIZER;
391 */
392 
393#define PTHREAD_ONCE_INITIALIZER  { TRUE, FALSE }
394 
395int pthread_once(
396  pthread_once_t  *once_control,
397  void           (*init_routine)(void)
398);
399
400/*
401 *  17.1.1 Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163
402 */
403
404int pthread_key_create(
405  pthread_key_t  *key,
406  void          (*destructor)( void * )
407);
408
409/*
410 *  17.1.2 Thread-Specific Data Management, P1003.1c/Draft 10, p. 165
411 */
412
413int pthread_setspecific(
414  pthread_key_t  key,
415  const void    *value
416);
417
418void *pthread_getspecific(
419  pthread_key_t  key
420);
421
422/*
423 *  17.1.3 Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167
424 */
425
426int pthread_key_delete(
427  pthread_key_t  key
428);
429
430/*
431 *  18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
432 */
433
434#define PTHREAD_CANCEL_ENABLE  0
435#define PTHREAD_CANCEL_DISABLE 1
436
437#define PTHREAD_CANCEL_DEFERRED 0
438#define PTHREAD_CANCEL_ASYNCHRONOUS 1
439
440int pthread_cancel(
441  pthread_t  thread
442);
443
444/*
445 *  18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183
446 */
447
448int pthread_setcancelstate(
449  int  state,
450  int *oldstate
451);
452
453int pthread_setcanceltype(
454  int  type,
455  int *oldtype
456);
457
458void pthread_testcancel( void );
459
460/*
461 *  18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184
462 */
463
464void pthread_cleanup_push(
465  void   (*routine)( void * ),
466  void    *arg
467);
468
469void pthread_cleanup_pop(
470  int    execute
471);
472
473#if defined(_POSIX_THREAD_CPUTIME)
474 
475/*
476 *  20.1.6 Accessing a Thread CPU-time Clock, P1003.4b/D8, p. 58
477 */
478 
479int pthread_getcpuclockid(
480  pthread_t      pid,
481  clockid_t *clock_id
482);
483 
484/*
485 *  20.1.7 CPU-time Clock Thread Creation Attribute, P1003.4b/D8, p. 59
486 */
487
488int pthread_attr_setcputime(
489  pthread_attr_t  *attr,
490  int              clock_allowed
491);
492
493int pthread_attr_getcputime(
494  pthread_attr_t  *attr,
495  int             *clock_allowed
496);
497
498#endif /* defined(_POSIX_THREAD_CPUTIME) */
499
500#endif /* defined(_POSIX_THREADS) */
501#endif
502/* end of include file */
Note: See TracBrowser for help on using the repository browser.