source: rtems/cpukit/score/src/thread.c @ 2afb22b

5
Last change on this file since 2afb22b was 3a659b04, checked in by Sebastian Huber <sebastian.huber@…>, on 12/09/16 at 06:19:22

score: Introduce _Internal_error()

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Initialize Thread Handler
5 *  @ingroup ScoreThread
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/threadimpl.h>
22#include <rtems/score/interr.h>
23#include <rtems/score/scheduler.h>
24#include <rtems/score/wkspace.h>
25
26#define THREAD_OFFSET_ASSERT( field ) \
27  RTEMS_STATIC_ASSERT( \
28    offsetof( Thread_Control, field ) == offsetof( Thread_Proxy_control, field ), \
29    field \
30  )
31
32THREAD_OFFSET_ASSERT( Object );
33THREAD_OFFSET_ASSERT( Join_queue );
34THREAD_OFFSET_ASSERT( current_state );
35THREAD_OFFSET_ASSERT( Real_priority );
36#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT)
37THREAD_OFFSET_ASSERT( resource_count );
38#endif
39THREAD_OFFSET_ASSERT( Scheduler );
40THREAD_OFFSET_ASSERT( Wait );
41THREAD_OFFSET_ASSERT( Timer );
42#if defined(RTEMS_MULTIPROCESSING)
43THREAD_OFFSET_ASSERT( receive_packet );
44#endif
45
46Thread_Information _Thread_Internal_information;
47
48void _Thread_Initialize_information(
49  Thread_Information  *information,
50  Objects_APIs         the_api,
51  uint16_t             the_class,
52  uint32_t             maximum,
53  bool                 is_string,
54  uint32_t             maximum_name_length
55)
56{
57  _Objects_Initialize_information(
58    &information->Objects,
59    the_api,
60    the_class,
61    maximum,
62    _Thread_Control_size,
63    is_string,
64    maximum_name_length,
65    NULL
66  );
67
68  _Freechain_Initialize(
69    &information->Free_thread_queue_heads,
70    _Workspace_Allocate_or_fatal_error,
71    _Objects_Maximum_per_allocation( maximum ),
72    THREAD_QUEUE_HEADS_SIZE( _Scheduler_Count )
73  );
74}
75
76void _Thread_Handler_initialization(void)
77{
78  rtems_stack_allocate_init_hook stack_allocate_init_hook =
79    rtems_configuration_get_stack_allocate_init_hook();
80  #if defined(RTEMS_MULTIPROCESSING)
81    uint32_t maximum_proxies =
82      _Configuration_MP_table->maximum_proxies;
83  #endif
84
85  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
86       rtems_configuration_get_stack_free_hook() == NULL)
87    _Internal_error( INTERNAL_ERROR_BAD_STACK_HOOK );
88
89  if ( stack_allocate_init_hook != NULL )
90    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
91
92  #if defined(RTEMS_MULTIPROCESSING)
93    _Thread_MP_Handler_initialization( maximum_proxies );
94  #endif
95
96  /*
97   *  Initialize the internal class of threads.  We need an IDLE thread
98   *  per CPU in an SMP system.  In addition, if this is a loosely
99   *  coupled multiprocessing system, account for the MPCI Server Thread.
100   */
101  _Thread_Initialize_information(
102    &_Thread_Internal_information,
103    OBJECTS_INTERNAL_API,
104    OBJECTS_INTERNAL_THREADS,
105    _Thread_Get_maximum_internal_threads(),
106    false,                      /* true if names for this object are strings */
107    8                           /* maximum length of each object's name */
108  );
109
110}
Note: See TracBrowser for help on using the repository browser.