source: rtems/cpukit/score/src/threadcreateidle.c @ 3380ee8

4.115
Last change on this file since 3380ee8 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
RevLine 
[e655f7e]1/**
2 *  @file
[05df0a8]3 *
[e655f7e]4 *  @brief Create Idle Thread
5 *  @ingroup ScoreThread
6 */
7
8/*
[06dcaf0]9 *  COPYRIGHT (c) 1989-2011.
[05df0a8]10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
[dcf3687]13 *  found in the file LICENSE in this distribution or at
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[05df0a8]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[5618c37a]21#include <rtems/score/threadimpl.h>
[c5831a3f]22#include <rtems/score/schedulerimpl.h>
[218286bc]23#include <rtems/score/stackimpl.h>
[976162a6]24#include <rtems/config.h>
[05df0a8]25
[3380ee8]26static void _Thread_Create_idle_for_cpu( Per_CPU_Control *cpu )
[05df0a8]27{
[477259c]28  Objects_Name    name;
29  Thread_Control *idle;
[6c71b25]30
[477259c]31  name.name_u32 = _Objects_Build_name( 'I', 'D', 'L', 'E' );
[05df0a8]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   */
[06dcaf0]38  idle = _Thread_Internal_allocate();
[05279b84]39
[05df0a8]40  _Thread_Initialize(
41    &_Thread_Internal_information,
[06dcaf0]42    idle,
[3380ee8]43    _Scheduler_Get_by_CPU( cpu ),
[05df0a8]44    NULL,        /* allocate the stack */
[8a331a5e]45    _Stack_Ensure_minimum( rtems_configuration_get_idle_task_stack_size() ),
[05df0a8]46    CPU_IDLE_TASK_IS_FP,
47    PRIORITY_MAXIMUM,
[aae7f1a1]48    true,        /* preemptable */
[05df0a8]49    THREAD_CPU_BUDGET_ALGORITHM_NONE,
50    NULL,        /* no budget algorithm callout */
51    0,           /* all interrupts enabled */
[6c71b25]52    name
[05df0a8]53  );
[05279b84]54
[05df0a8]55  /*
56   *  WARNING!!! This is necessary to "kick" start the system and
57   *             MUST be done before _Thread_Start is invoked.
58   */
[3380ee8]59  cpu->heir      =
60  cpu->executing = idle;
[05279b84]61
[05df0a8]62  _Thread_Start(
[06dcaf0]63    idle,
[05df0a8]64    THREAD_START_NUMERIC,
[3954767]65    rtems_configuration_get_idle_task(),
[05df0a8]66    NULL,
[1ccb64e1]67    0,
[3380ee8]68    cpu
[05df0a8]69  );
[06dcaf0]70}
71
72void _Thread_Create_idle( void )
73{
[3380ee8]74  uint32_t cpu_count = _SMP_Get_processor_count();
75  uint32_t cpu_index;
[477259c]76
[3380ee8]77  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
78    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
[05279b84]79
[3380ee8]80    if ( _Per_CPU_Is_processor_started( cpu ) ) {
81      _Thread_Create_idle_for_cpu( cpu );
[c5831a3f]82    }
[477259c]83  }
[05df0a8]84}
Note: See TracBrowser for help on using the repository browser.