source: rtems/cpukit/score/src/threadcreateidle.c @ 6b0a729b

5
Last change on this file since 6b0a729b was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

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.5 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Create Idle Thread
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/assert.h>
23#include <rtems/score/schedulerimpl.h>
24#include <rtems/score/stackimpl.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/score/userextimpl.h>
27#include <rtems/config.h>
28
29static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu )
30{
31  Objects_Name             name;
32  Thread_Control          *idle;
33  const Scheduler_Control *scheduler;
34
35  scheduler = _Scheduler_Get_by_CPU( cpu );
36
37#if defined(RTEMS_SMP)
38  if (scheduler == NULL) {
39    return;
40  }
41#endif
42
43  name.name_u32 = _Objects_Build_name( 'I', 'D', 'L', 'E' );
44
45  /*
46   *  The entire workspace is zeroed during its initialization.  Thus, all
47   *  fields not explicitly assigned were explicitly zeroed by
48   *  _Workspace_Initialization.
49   */
50  idle = _Thread_Internal_allocate();
51  _Assert( idle != NULL );
52
53  _Thread_Initialize(
54    &_Thread_Information,
55    idle,
56    scheduler,
57    NULL,        /* allocate the stack */
58    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
59    CPU_IDLE_TASK_IS_FP,
60    _Scheduler_Map_priority( scheduler, scheduler->maximum_priority ),
61    true,        /* preemptable */
62    THREAD_CPU_BUDGET_ALGORITHM_NONE,
63    NULL,        /* no budget algorithm callout */
64    0,           /* all interrupts enabled */
65    name
66  );
67
68  /*
69   *  WARNING!!! This is necessary to "kick" start the system and
70   *             MUST be done before _Thread_Start is invoked.
71   */
72  cpu->heir      =
73  cpu->executing = idle;
74
75  idle->is_idle = true;
76  idle->Start.Entry.adaptor = _Thread_Entry_adaptor_idle;
77  idle->Start.Entry.Kinds.Idle.entry = rtems_configuration_get_idle_task();
78
79  _Thread_Load_environment( idle );
80
81  idle->current_state = STATES_READY;
82  _Scheduler_Start_idle( scheduler, idle, cpu );
83  _User_extensions_Thread_start( idle );
84}
85
86void _Thread_Create_idle( void )
87{
88  uint32_t cpu_count = _SMP_Get_processor_count();
89  uint32_t cpu_index;
90
91  _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING );
92
93  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
94    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
95
96    if ( _Per_CPU_Is_processor_online( cpu ) ) {
97      _Thread_Create_idle_for_CPU( cpu );
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.