summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/schedulersmpstartidle.c
blob: d396a159fe723fda671bbc441238093c5ae60070 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (c) 2013, 2016 embedded brains GmbH.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#if HAVE_CONFIG_H
  #include "config.h"
#endif

#include <rtems/score/schedulersmpimpl.h>

void _Scheduler_SMP_Start_idle(
  const Scheduler_Control *scheduler,
  Thread_Control          *idle,
  Per_CPU_Control         *cpu
)
{
  Scheduler_Context     *context;
  Scheduler_SMP_Context *self;
  Scheduler_SMP_Node    *node;

  context = _Scheduler_Get_context( scheduler );
  self = _Scheduler_SMP_Get_self( context );
  node = _Scheduler_SMP_Thread_get_node( idle );

  _Scheduler_Thread_change_state( idle, THREAD_SCHEDULER_SCHEDULED );
  node->state = SCHEDULER_SMP_NODE_SCHEDULED;

  _Thread_Set_CPU( idle, cpu );
  _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node.Chain );
  _Scheduler_SMP_Release_idle_thread( &self->Base, idle );
}