source: rtems/cpukit/score/src/thread.c @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.4 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/objectimpl.h>
24#include <rtems/score/scheduler.h>
25#include <rtems/score/wkspace.h>
26
27#define THREAD_OFFSET_ASSERT( field ) \
28  RTEMS_STATIC_ASSERT( \
29    offsetof( Thread_Control, field ) == offsetof( Thread_Proxy_control, field ), \
30    field \
31  )
32
33THREAD_OFFSET_ASSERT( Object );
34THREAD_OFFSET_ASSERT( Join_queue );
35THREAD_OFFSET_ASSERT( current_state );
36THREAD_OFFSET_ASSERT( Real_priority );
37#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT)
38THREAD_OFFSET_ASSERT( resource_count );
39#endif
40THREAD_OFFSET_ASSERT( Scheduler );
41THREAD_OFFSET_ASSERT( Wait );
42THREAD_OFFSET_ASSERT( Timer );
43#if defined(RTEMS_MULTIPROCESSING)
44THREAD_OFFSET_ASSERT( receive_packet );
45#endif
46
47void _Thread_Initialize_information( Thread_Information *information )
48{
49  _Objects_Initialize_information( &information->Objects );
50
51  _Freechain_Initialize(
52    &information->Thread_queue_heads.Free,
53    information->Thread_queue_heads.initial,
54    _Objects_Get_maximum_index( &information->Objects ),
55    _Thread_queue_Heads_size
56  );
57}
58
59void _Thread_Handler_initialization(void)
60{
61  rtems_stack_allocate_init_hook stack_allocate_init_hook =
62    rtems_configuration_get_stack_allocate_init_hook();
63  #if defined(RTEMS_MULTIPROCESSING)
64    uint32_t maximum_proxies =
65      _Configuration_MP_table->maximum_proxies;
66  #endif
67
68  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
69       rtems_configuration_get_stack_free_hook() == NULL)
70    _Internal_error( INTERNAL_ERROR_BAD_STACK_HOOK );
71
72  if ( stack_allocate_init_hook != NULL )
73    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
74
75  #if defined(RTEMS_MULTIPROCESSING)
76    _Thread_MP_Handler_initialization( maximum_proxies );
77  #endif
78
79  /*
80   *  Initialize the internal class of threads.  We need an IDLE thread
81   *  per CPU in an SMP system.  In addition, if this is a loosely
82   *  coupled multiprocessing system, account for the MPCI Server Thread.
83   */
84  _Thread_Initialize_information( &_Thread_Information );
85}
Note: See TracBrowser for help on using the repository browser.