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

4.115
Last change on this file since edde99b was edde99b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/14/13 at 12:26:34

score: Rename rtems_smp_get_number_of_processors()

Rename in rtems_smp_get_processor_count(). Always provide
<rtems/score/smp.h> and <rtems/rtems/smp.h>. Add
_SMP_Get_processor_count(). This function will be a compile time
constant defined to be one on uni-processor configurations. This allows
iterations over all processors without overhead on uni-processor
configurations.

  • Property mode set to 100644
File size: 2.3 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/apiext.h>
23#include <rtems/score/context.h>
24#include <rtems/score/interr.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/object.h>
27#include <rtems/score/priority.h>
28#include <rtems/score/states.h>
29#include <rtems/score/sysstate.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/threadq.h>
32#include <rtems/score/wkspace.h>
33#include <rtems/config.h>
34#if defined(RTEMS_SMP)
35  #include <rtems/score/smp.h>
36#endif
37
38static inline void _Thread_Create_idle_helper(
39  uint32_t name_u32,
40  int      cpu
41)
42{
43  Per_CPU_Control *per_cpu;
44  Objects_Name     name;
45  Thread_Control  *idle;
46
47  per_cpu = &_Per_CPU_Information[ cpu ];
48  name.name_u32 = name_u32;
49
50  /*
51   *  The entire workspace is zeroed during its initialization.  Thus, all
52   *  fields not explicitly assigned were explicitly zeroed by
53   *  _Workspace_Initialization.
54   */
55  idle = _Thread_Internal_allocate();
56
57  _Thread_Initialize(
58    &_Thread_Internal_information,
59    idle,
60    NULL,        /* allocate the stack */
61    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
62    CPU_IDLE_TASK_IS_FP,
63    PRIORITY_MAXIMUM,
64    true,        /* preemptable */
65    THREAD_CPU_BUDGET_ALGORITHM_NONE,
66    NULL,        /* no budget algorithm callout */
67    0,           /* all interrupts enabled */
68    name
69  );
70
71  /*
72   *  WARNING!!! This is necessary to "kick" start the system and
73   *             MUST be done before _Thread_Start is invoked.
74   */
75  per_cpu->heir      =
76  per_cpu->executing = idle;
77
78  _Thread_Start(
79    idle,
80    THREAD_START_NUMERIC,
81    rtems_configuration_get_idle_task(),
82    NULL,
83    0
84  );
85}
86
87void _Thread_Create_idle( void )
88{
89  #if defined(RTEMS_SMP)
90    int cpu;
91
92    for ( cpu=0 ; cpu < _SMP_Get_processor_count() ; cpu++ ) {
93      _Thread_Create_idle_helper(
94        _Objects_Build_name( 'I', 'D', 'L', 'E' ),
95        cpu
96      );
97    }
98  #else
99    _Thread_Create_idle_helper(_Objects_Build_name( 'I', 'D', 'L', 'E' ), 0);
100  #endif
101}
Note: See TracBrowser for help on using the repository browser.