source: rtems/cpukit/score/src/threadcreateidle.c @ 1ccb64e1

4.115
Last change on this file since 1ccb64e1 was 1ccb64e1, checked in by Sebastian Huber <sebastian.huber@…>, on 06/06/13 at 13:28:41

scheduler: Add start idle thread operation

Add and use _Scheduler_Start_idle().

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