source: rtems/cpukit/score/src/threadcreateidle.c @ 27270b0d

4.115
Last change on this file since 27270b0d was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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