source: rtems/cpukit/score/src/threadcreateidle.c @ 25f5730f

4.115
Last change on this file since 25f5730f was 3380ee8, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/14 at 05:46:53

score: Use common names for per-CPU variables

Use "cpu" for an arbitrary Per_CPU_Control variable.

Use "cpu_self" for the Per_CPU_Control of the current processor.

Use "cpu_index" for an arbitrary processor index.

Use "cpu_index_self" for the processor index of the current processor.

Use "cpu_count" for the processor count obtained via
_SMP_Get_processor_count().

Use "cpu_max" for the processor maximum obtained by
rtems_configuration_get_maximum_processors().

  • Property mode set to 100644
File size: 2.0 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/config.h>
25
26static void _Thread_Create_idle_for_cpu( Per_CPU_Control *cpu )
27{
28  Objects_Name    name;
29  Thread_Control *idle;
30
31  name.name_u32 = _Objects_Build_name( 'I', 'D', 'L', 'E' );
32
33  /*
34   *  The entire workspace is zeroed during its initialization.  Thus, all
35   *  fields not explicitly assigned were explicitly zeroed by
36   *  _Workspace_Initialization.
37   */
38  idle = _Thread_Internal_allocate();
39
40  _Thread_Initialize(
41    &_Thread_Internal_information,
42    idle,
43    _Scheduler_Get_by_CPU( cpu ),
44    NULL,        /* allocate the stack */
45    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
46    CPU_IDLE_TASK_IS_FP,
47    PRIORITY_MAXIMUM,
48    true,        /* preemptable */
49    THREAD_CPU_BUDGET_ALGORITHM_NONE,
50    NULL,        /* no budget algorithm callout */
51    0,           /* all interrupts enabled */
52    name
53  );
54
55  /*
56   *  WARNING!!! This is necessary to "kick" start the system and
57   *             MUST be done before _Thread_Start is invoked.
58   */
59  cpu->heir      =
60  cpu->executing = idle;
61
62  _Thread_Start(
63    idle,
64    THREAD_START_NUMERIC,
65    rtems_configuration_get_idle_task(),
66    NULL,
67    0,
68    cpu
69  );
70}
71
72void _Thread_Create_idle( void )
73{
74  uint32_t cpu_count = _SMP_Get_processor_count();
75  uint32_t cpu_index;
76
77  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
78    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
79
80    if ( _Per_CPU_Is_processor_started( cpu ) ) {
81      _Thread_Create_idle_for_cpu( cpu );
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.