RTEMS
threadstartmultitasking.c
Go to the documentation of this file.
1 
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 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <rtems/score/threadimpl.h>
22 #include <rtems/score/assert.h>
23 
25 {
26  Per_CPU_Control *cpu_self = _Per_CPU_Get();
27  Thread_Control *heir;
28 
29 #if defined(RTEMS_SMP)
30  _Per_CPU_State_change( cpu_self, PER_CPU_STATE_UP );
31 
32  /*
33  * Threads begin execution in the _Thread_Handler() function. This
34  * function will set the thread dispatch disable level to zero.
35  */
36  cpu_self->thread_dispatch_disable_level = 1;
37 #endif
38 
39  heir = _Thread_Get_heir_and_make_it_executing( cpu_self );
40 
42 
43 #if defined(RTEMS_SMP)
44  _CPU_SMP_Prepare_start_multitasking();
45 #endif
46 
47 #if defined(_CPU_Start_multitasking)
48  _CPU_Start_multitasking( &heir->Registers );
49 #elif defined(RTEMS_SMP)
50  {
51  Context_Control trash;
52 
53  /*
54  * Mark the trash context as executing to not confuse the
55  * _CPU_Context_switch(). On SMP configurations the context switch
56  * contains a special hand over section to atomically switch from the
57  * executing to the currently selected heir thread.
58  */
59  _CPU_Context_Set_is_executing( &trash, true );
60  _CPU_Context_switch( &trash, &heir->Registers );
62  }
63 #else
65 #endif
66 }
SPARC basic context.
Definition: cpu.h:318
Information for the Assert Handler.
void _CPU_Context_switch(Context_Control *run, Context_Control *heir)
SPARC specific context switch.
Per CPU Core Structure.
Definition: percpu.h:347
void _Thread_Start_multitasking(void)
Starts thread multitasking.
#define _CPU_Context_Restart_self(_the_context)
Definition: cpu.h:886
Normal multitasking state.
Definition: percpu.h:168
static void _Profiling_Thread_dispatch_disable(Per_CPU_Control *cpu, uint32_t previous_thread_dispatch_disable_level)
Disables the thread dispatch if the previous thread dispatch disable level is zero.
Definition: profiling.h:51
volatile uint32_t thread_dispatch_disable_level
The thread dispatch critical section nesting counter which is used to prevent context switches at ino...
Definition: percpu.h:385
Inlined Routines from the Thread Handler.
Context_Control Registers
Definition: thread.h:830
static __inline__ Thread_Control * _Thread_Get_heir_and_make_it_executing(Per_CPU_Control *cpu_self)
Gets the heir of the processor and makes it executing.
Definition: threadimpl.h:1135
#define RTEMS_UNREACHABLE()
Tells the compiler that this program point is unreachable.
Definition: basedefs.h:860