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

4.115
Last change on this file since 2d84c4e was 2d84c4e, checked in by Sebastian Huber <sebastian.huber@…>, on 02/13/15 at 21:07:45

score: Mention ticket in comment

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[e655f7e]1/**
2 *  @file
[05df0a8]3 *
[e655f7e]4 *  @brief Start Thread Multitasking
5 *  @ingroup ScoreThread
6 */
7
8/*
[6a07436]9 *  COPYRIGHT (c) 1989-2006.
[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>
[05df0a8]22
[514705d]23void _Thread_Start_multitasking( void )
[05df0a8]24{
[3380ee8]25  Per_CPU_Control *cpu_self = _Per_CPU_Get();
[7ee4e72]26  Thread_Control  *heir;
[05df0a8]27
[b4b309c]28#if defined(RTEMS_SMP)
[3380ee8]29  _Per_CPU_State_change( cpu_self, PER_CPU_STATE_UP );
[05df0a8]30
[514705d]31  /*
32   * Threads begin execution in the _Thread_Handler() function.   This
[38b59a6]33   * function will set the thread dispatch disable level to zero.
[514705d]34   */
[3380ee8]35  cpu_self->thread_dispatch_disable_level = 1;
[7ee4e72]36#endif
37
[38b59a6]38  heir = _Thread_Get_heir_and_make_it_executing( cpu_self );
[05df0a8]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
[b4b309c]58   if ( heir->fp_context != NULL )
59     _Context_Restore_fp( &heir->fp_context );
60#endif
61
[3380ee8]62  _Profiling_Thread_dispatch_disable( cpu_self, 0 );
[383b2d3]63
[152ad7d1]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
[2d84c4e]72   * relevant.  See https://devel.rtems.org/ticket/2268.
[152ad7d1]73   */
74  _CPU_Context_Set_is_executing( &heir->Registers, true );
75#endif
76
[86c847c1]77#if defined(_CPU_Start_multitasking)
[383b2d3]78  _CPU_Start_multitasking( &heir->Registers );
[86c847c1]79#else
[383b2d3]80  _CPU_Context_Restart_self( &heir->Registers );
[86c847c1]81#endif
[05df0a8]82}
Note: See TracBrowser for help on using the repository browser.