source: rtems/cpukit/score/src/threadstartmultitasking.c @ 1506658c

5
Last change on this file since 1506658c was 7fcb71a, checked in by Sebastian Huber <sebastian.huber@…>, on 02/17/15 at 12:43:57

score: Fix _Thread_Start_multitasking() on SMP

Close #2268.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Start Thread Multitasking
5 *  @ingroup ScoreThread
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2006.
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
23void _Thread_Start_multitasking( void )
24{
25  Per_CPU_Control *cpu_self = _Per_CPU_Get();
26  Thread_Control  *heir;
27
28#if defined(RTEMS_SMP)
29  _Per_CPU_State_change( cpu_self, PER_CPU_STATE_UP );
30
31  /*
32   * Threads begin execution in the _Thread_Handler() function.   This
33   * function will set the thread dispatch disable level to zero.
34   */
35  cpu_self->thread_dispatch_disable_level = 1;
36#endif
37
38  heir = _Thread_Get_heir_and_make_it_executing( cpu_self );
39
40  _Profiling_Thread_dispatch_disable( cpu_self, 0 );
41
42#if defined(RTEMS_SMP)
43  _CPU_SMP_Prepare_start_multitasking();
44#endif
45
46#if defined(_CPU_Start_multitasking)
47  _CPU_Start_multitasking( &heir->Registers );
48#elif defined(RTEMS_SMP)
49  {
50    Context_Control trash;
51
52    /*
53     * Mark the trash context as executing to not confuse the
54     * _CPU_Context_switch().  On SMP configurations the context switch
55     * contains a special hand over section to atomically switch from the
56     * executing to the currently selected heir thread.
57     */
58    _CPU_Context_Set_is_executing( &trash, true );
59    _CPU_Context_switch( &trash, &heir->Registers );
60  }
61#else
62  _CPU_Context_Restart_self( &heir->Registers );
63#endif
64}
Note: See TracBrowser for help on using the repository browser.