source: rtems/cpukit/score/src/thread.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: 3.4 KB
Line 
1/*
2 *  Thread Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2011.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/config.h>
19#include <rtems/score/apiext.h>
20#include <rtems/score/context.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/priority.h>
25#include <rtems/score/scheduler.h>
26#include <rtems/score/states.h>
27#include <rtems/score/sysstate.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30#include <rtems/score/wkspace.h>
31#include <rtems/config.h>
32
33#if defined(RTEMS_SMP)
34  #include <rtems/bspsmp.h>
35#endif
36
37/*
38 *  _Thread_Handler_initialization
39 *
40 *  This routine initializes all thread manager related data structures.
41 *
42 *  Input parameters:   NONE
43 *
44 *  Output parameters:  NONE
45 */
46
47void _Thread_Handler_initialization(void)
48{
49  uint32_t ticks_per_timeslice =
50    rtems_configuration_get_ticks_per_timeslice();
51  uint32_t maximum_extensions =
52    rtems_configuration_get_maximum_extensions();
53  rtems_stack_allocate_init_hook stack_allocate_init_hook =
54    rtems_configuration_get_stack_allocate_init_hook();
55  uint32_t     maximum_internal_threads;
56  #if defined(RTEMS_MULTIPROCESSING)
57    uint32_t maximum_proxies =
58      _Configuration_MP_table->maximum_proxies;
59  #endif
60
61  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
62       rtems_configuration_get_stack_free_hook() == NULL)
63    _Internal_error_Occurred(
64      INTERNAL_ERROR_CORE,
65      true,
66      INTERNAL_ERROR_BAD_STACK_HOOK
67    );
68
69  if ( stack_allocate_init_hook != NULL )
70    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
71
72  _Thread_Dispatch_necessary = false;
73  _Thread_Executing         = NULL;
74  _Thread_Heir              = NULL;
75#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
76  _Thread_Allocated_fp      = NULL;
77#endif
78
79  _Thread_Maximum_extensions = maximum_extensions;
80
81  _Thread_Ticks_per_timeslice  = ticks_per_timeslice;
82
83  #if defined(RTEMS_MULTIPROCESSING)
84    _Thread_MP_Handler_initialization( maximum_proxies );
85  #endif
86
87  /*
88   *  Initialize the internal class of threads.  We need an IDLE thread
89   *  per CPU in an SMP system.  In addition, if this is a loosely
90   *  coupled multiprocessing system, account for the MPCI Server Thread.
91   */
92  #if defined(RTEMS_SMP)
93    maximum_internal_threads = rtems_configuration_smp_maximum_processors;
94  #else
95    maximum_internal_threads = 1;
96  #endif
97
98  #if defined(RTEMS_MULTIPROCESSING)
99    if ( _System_state_Is_multiprocessing )
100      maximum_internal_threads += 1;
101  #endif
102
103  _Objects_Initialize_information(
104    &_Thread_Internal_information,
105    OBJECTS_INTERNAL_API,
106    OBJECTS_INTERNAL_THREADS,
107    maximum_internal_threads,
108    sizeof( Thread_Control ),
109                                /* size of this object's control block */
110    false,                      /* true if names for this object are strings */
111    8                           /* maximum length of each object's name */
112    #if defined(RTEMS_MULTIPROCESSING)
113      ,
114      false,                      /* true if this is a global object class */
115      NULL                        /* Proxy extraction support callout */
116    #endif
117  );
118
119}
Note: See TracBrowser for help on using the repository browser.