source: rtems/cpukit/posix/src/pthreadinitthreads.c @ 3be0c9a

4.115
Last change on this file since 3be0c9a was 3be0c9a, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/12 at 13:51:25

score: Add and use <rtems/score/userextimpl.h>

This file contains the parts of <rtems/score/userext.h> that are only
necessary for the RTEMS implementation.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#if HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <errno.h>
15#include <pthread.h>
16#include <limits.h>
17
18#include <rtems/system.h>
19#include <rtems/config.h>
20#include <rtems/score/apiext.h>
21#include <rtems/score/stack.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/posix/cancel.h>
25#include <rtems/posix/pthread.h>
26#include <rtems/posix/priority.h>
27#include <rtems/posix/psignal.h>
28#include <rtems/posix/config.h>
29#include <rtems/posix/key.h>
30#include <rtems/posix/time.h>
31
32/*
33 *  _POSIX_Threads_Initialize_user_threads_body
34 *
35 *  This routine creates and starts all configured user
36 *  initialization threads.
37 *
38 *  Input parameters: NONE
39 *
40 *  Output parameters:  NONE
41 */
42
43void _POSIX_Threads_Initialize_user_threads_body(void)
44{
45  int                                 status;
46  uint32_t                            index;
47  uint32_t                            maximum;
48  posix_initialization_threads_table *user_threads;
49  pthread_t                           thread_id;
50  pthread_attr_t                      attr;
51
52  user_threads = Configuration_POSIX_API.User_initialization_threads_table;
53  maximum      = Configuration_POSIX_API.number_of_initialization_threads;
54
55  if ( !user_threads || maximum == 0 )
56    return;
57
58  /*
59   *  Be careful .. if the default attribute set changes, this may need to.
60   *
61   *  Setting the attributes explicitly is critical, since we don't want
62   *  to inherit the idle tasks attributes.
63   */
64
65  for ( index=0 ; index < maximum ; index++ ) {
66    /*
67     * There is no way for these calls to fail in this situation.
68     */
69    (void) pthread_attr_init( &attr );
70    (void) pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
71    (void) pthread_attr_setstacksize(&attr, user_threads[ index ].stack_size);
72
73    status = pthread_create(
74      &thread_id,
75      &attr,
76      user_threads[ index ].thread_entry,
77      NULL
78    );
79    if ( status )
80      _Internal_error_Occurred( INTERNAL_ERROR_POSIX_API, true, status );
81  }
82}
83
Note: See TracBrowser for help on using the repository browser.