source: rtems/cpukit/score/src/threadstartmultitasking.c @ 2d84c4e

4.11
Last change on this file since 2d84c4e was 2d84c4e, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 13, 2015 at 9:07:45 PM

score: Mention ticket in comment

  • Property mode set to 100644
File size: 2.3 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   /*
41    * Get the init task(s) running.
42    *
43    * Note: Thread_Dispatch() is normally used to dispatch threads.  As
44    *       part of its work, Thread_Dispatch() restores floating point
45    *       state for the heir task.
46    *
47    *       This code avoids Thread_Dispatch(), and so we have to restore
48    *       (actually initialize) the floating point state "by hand".
49    *
50    *       Ignore the CPU_USE_DEFERRED_FP_SWITCH because we must always
51    *       switch in the first thread if it is FP.
52    */
53#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
54   /*
55    *  don't need to worry about saving BSP's floating point state
56    */
57
58   if ( heir->fp_context != NULL )
59     _Context_Restore_fp( &heir->fp_context );
60#endif
61
62  _Profiling_Thread_dispatch_disable( cpu_self, 0 );
63
64#if defined(RTEMS_SMP)
65  /*
66   * The _CPU_Context_Restart_self() implementations usually assume that self
67   * context is executing.
68   *
69   * FIXME: We have a race condition here in case another thread already
70   * performed scheduler operations and moved our heir thread to another
71   * processor.  The time frame for this is likely too small to be practically
72   * relevant.  See https://devel.rtems.org/ticket/2268.
73   */
74  _CPU_Context_Set_is_executing( &heir->Registers, true );
75#endif
76
77#if defined(_CPU_Start_multitasking)
78  _CPU_Start_multitasking( &heir->Registers );
79#else
80  _CPU_Context_Restart_self( &heir->Registers );
81#endif
82}
Note: See TracBrowser for help on using the repository browser.