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/userext.h> |
---|
31 | #include <rtems/score/wkspace.h> |
---|
32 | #include <rtems/config.h> |
---|
33 | |
---|
34 | #if defined(RTEMS_SMP) |
---|
35 | #include <rtems/bspsmp.h> |
---|
36 | #endif |
---|
37 | |
---|
38 | /* |
---|
39 | * _Thread_Handler_initialization |
---|
40 | * |
---|
41 | * This routine initializes all thread manager related data structures. |
---|
42 | * |
---|
43 | * Input parameters: NONE |
---|
44 | * |
---|
45 | * Output parameters: NONE |
---|
46 | */ |
---|
47 | |
---|
48 | void _Thread_Handler_initialization(void) |
---|
49 | { |
---|
50 | uint32_t ticks_per_timeslice = |
---|
51 | rtems_configuration_get_ticks_per_timeslice(); |
---|
52 | uint32_t maximum_extensions = |
---|
53 | rtems_configuration_get_maximum_extensions(); |
---|
54 | rtems_stack_allocate_init_hook stack_allocate_init_hook = |
---|
55 | rtems_configuration_get_stack_allocate_init_hook(); |
---|
56 | uint32_t maximum_internal_threads; |
---|
57 | #if defined(RTEMS_MULTIPROCESSING) |
---|
58 | uint32_t maximum_proxies = |
---|
59 | _Configuration_MP_table->maximum_proxies; |
---|
60 | #endif |
---|
61 | |
---|
62 | if ( rtems_configuration_get_stack_allocate_hook() == NULL || |
---|
63 | rtems_configuration_get_stack_free_hook() == NULL) |
---|
64 | _Internal_error_Occurred( |
---|
65 | INTERNAL_ERROR_CORE, |
---|
66 | true, |
---|
67 | INTERNAL_ERROR_BAD_STACK_HOOK |
---|
68 | ); |
---|
69 | |
---|
70 | if ( stack_allocate_init_hook != NULL ) |
---|
71 | (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() ); |
---|
72 | |
---|
73 | _Thread_Dispatch_necessary = false; |
---|
74 | _Thread_Executing = NULL; |
---|
75 | _Thread_Heir = NULL; |
---|
76 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
77 | _Thread_Allocated_fp = NULL; |
---|
78 | #endif |
---|
79 | |
---|
80 | _Thread_Maximum_extensions = maximum_extensions; |
---|
81 | |
---|
82 | _Thread_Ticks_per_timeslice = ticks_per_timeslice; |
---|
83 | |
---|
84 | #if defined(RTEMS_MULTIPROCESSING) |
---|
85 | _Thread_MP_Handler_initialization( maximum_proxies ); |
---|
86 | #endif |
---|
87 | |
---|
88 | /* |
---|
89 | * Initialize the internal class of threads. We need an IDLE thread |
---|
90 | * per CPU in an SMP system. In addition, if this is a loosely |
---|
91 | * coupled multiprocessing system, account for the MPCI Server Thread. |
---|
92 | */ |
---|
93 | #if defined(RTEMS_SMP) |
---|
94 | maximum_internal_threads = rtems_configuration_smp_maximum_processors; |
---|
95 | #else |
---|
96 | maximum_internal_threads = 1; |
---|
97 | #endif |
---|
98 | |
---|
99 | #if defined(RTEMS_MULTIPROCESSING) |
---|
100 | if ( _System_state_Is_multiprocessing ) |
---|
101 | maximum_internal_threads += 1; |
---|
102 | #endif |
---|
103 | |
---|
104 | _Objects_Initialize_information( |
---|
105 | &_Thread_Internal_information, |
---|
106 | OBJECTS_INTERNAL_API, |
---|
107 | OBJECTS_INTERNAL_THREADS, |
---|
108 | maximum_internal_threads, |
---|
109 | sizeof( Thread_Control ), |
---|
110 | /* size of this object's control block */ |
---|
111 | false, /* true if names for this object are strings */ |
---|
112 | 8 /* maximum length of each object's name */ |
---|
113 | #if defined(RTEMS_MULTIPROCESSING) |
---|
114 | , |
---|
115 | false, /* true if this is a global object class */ |
---|
116 | NULL /* Proxy extraction support callout */ |
---|
117 | #endif |
---|
118 | ); |
---|
119 | |
---|
120 | } |
---|