source: rtems/cpukit/score/src/threadcreateidle.c @ bbd6d27a

5
Last change on this file since bbd6d27a was c284a16, checked in by Sebastian Huber <sebastian.huber@…>, on 02/17/16 at 14:34:51

score: Rename Per_CPU_Control::started

Rename Per_CPU_Control::started into Per_CPU_Control::online to match
standard nomenclature.

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