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

5
Last change on this file since ccd5434 was ccd5434, checked in by Sebastian Huber <sebastian.huber@…>, on 01/07/16 at 08:55:45

score: Introduce Thread_Entry_information

This avoids potential dead code in _Thread_Handler(). It gets rid of
the dangerous function pointer casts.

Update #2514.

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