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

4.11
Last change on this file since e3be691 was e3be691, checked in by Sebastian Huber <sebastian.huber@…>, on May 27, 2013 at 3:31:46 PM

score: Remove idle field of Per_CPU_Control

This field is unused except for special case simulator clock drivers.
In these places use an alternative. Add and use
_Thread_Set_global_exit_status() and _Thread_Get_global_exit_status().

  • 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.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  /*
58   *  This is only called during initialization and we better be sure
59   *  that when _Thread_Initialize unnests dispatch that we do not
60   *  do anything stupid.
61   */
62  _Thread_Disable_dispatch();
63
64  _Thread_Initialize(
65    &_Thread_Internal_information,
66    idle,
67    NULL,        /* allocate the stack */
68    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
69    CPU_IDLE_TASK_IS_FP,
70    PRIORITY_MAXIMUM,
71    true,        /* preemptable */
72    THREAD_CPU_BUDGET_ALGORITHM_NONE,
73    NULL,        /* no budget algorithm callout */
74    0,           /* all interrupts enabled */
75    name
76  );
77
78  _Thread_Unnest_dispatch();
79
80  /*
81   *  WARNING!!! This is necessary to "kick" start the system and
82   *             MUST be done before _Thread_Start is invoked.
83   */
84  per_cpu->heir      =
85  per_cpu->executing = idle;
86
87  _Thread_Start(
88    idle,
89    THREAD_START_NUMERIC,
90    rtems_configuration_get_idle_task(),
91    NULL,
92    0
93  );
94}
95
96void _Thread_Create_idle( void )
97{
98  #if defined(RTEMS_SMP)
99    int cpu;
100
101    for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
102      _Thread_Create_idle_helper(
103        _Objects_Build_name( 'I', 'D', 'L', 'E' ),
104        cpu
105      );
106    }
107  #else
108    _Thread_Create_idle_helper(_Objects_Build_name( 'I', 'D', 'L', 'E' ), 0);
109  #endif
110}
Note: See TracBrowser for help on using the repository browser.