source: rtems/cpukit/score/src/threadcreateidle.c @ 17e09f8e

4.115
Last change on this file since 17e09f8e was e655f7e, checked in by Alex Ivanov <alexivanov97@…>, on 11/29/12 at 18:39:19

score misc: Score misc: Clean up Doxygen #5

  • Property mode set to 100644
File size: 2.6 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  Objects_Name    name;
44  Thread_Control *idle;
45
46  name.name_u32 = name_u32;
47
48  /*
49   *  The entire workspace is zeroed during its initialization.  Thus, all
50   *  fields not explicitly assigned were explicitly zeroed by
51   *  _Workspace_Initialization.
52   */
53  idle = _Thread_Internal_allocate();
54
55  /*
56   *  This is only called during initialization and we better be sure
57   *  that when _Thread_Initialize unnests dispatch that we do not
58   *  do anything stupid.
59   */
60  _Thread_Disable_dispatch();
61
62  _Thread_Initialize(
63    &_Thread_Internal_information,
64    idle,
65    NULL,        /* allocate the stack */
66    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
67    CPU_IDLE_TASK_IS_FP,
68    PRIORITY_MAXIMUM,
69    true,        /* preemptable */
70    THREAD_CPU_BUDGET_ALGORITHM_NONE,
71    NULL,        /* no budget algorithm callout */
72    0,           /* all interrupts enabled */
73    name
74  );
75
76  _Thread_Unnest_dispatch();
77
78  /*
79   *  WARNING!!! This is necessary to "kick" start the system and
80   *             MUST be done before _Thread_Start is invoked.
81   */
82  _Per_CPU_Information[ cpu ].idle      =
83  _Per_CPU_Information[ cpu ].heir      =
84  _Per_CPU_Information[ cpu ].executing = idle;
85
86  _Thread_Start(
87    idle,
88    THREAD_START_NUMERIC,
89    rtems_configuration_get_idle_task(),
90    NULL,
91    0
92  );
93}
94
95void _Thread_Create_idle( void )
96{
97  #if defined(RTEMS_SMP)
98    int cpu;
99
100    for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
101      _Thread_Create_idle_helper(
102        _Objects_Build_name( 'I', 'D', 'L', 'E' ),
103        cpu
104      );
105    }
106  #else
107    _Thread_Create_idle_helper(_Objects_Build_name( 'I', 'D', 'L', 'E' ), 0);
108  #endif
109}
Note: See TracBrowser for help on using the repository browser.