1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initializes Thread and Executes it |
---|
5 | * |
---|
6 | * @ingroup ScoreThread |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-1999. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/score/threadimpl.h> |
---|
23 | #include <rtems/score/isrlevel.h> |
---|
24 | #include <rtems/score/userextimpl.h> |
---|
25 | |
---|
26 | bool _Thread_Start( |
---|
27 | Thread_Control *the_thread, |
---|
28 | const Thread_Entry_information *entry, |
---|
29 | ISR_lock_Context *lock_context |
---|
30 | ) |
---|
31 | { |
---|
32 | Per_CPU_Control *cpu_self; |
---|
33 | |
---|
34 | _Thread_State_acquire_critical( the_thread, lock_context ); |
---|
35 | |
---|
36 | if ( !_States_Is_dormant( the_thread->current_state ) ) { |
---|
37 | _Thread_State_release( the_thread, lock_context ); |
---|
38 | return false; |
---|
39 | } |
---|
40 | |
---|
41 | the_thread->Start.Entry = *entry; |
---|
42 | _Thread_Load_environment( the_thread ); |
---|
43 | _Thread_Clear_state_locked( the_thread, STATES_ALL_SET ); |
---|
44 | |
---|
45 | cpu_self = _Thread_Dispatch_disable_critical( lock_context ); |
---|
46 | _Thread_State_release( the_thread, lock_context ); |
---|
47 | |
---|
48 | _User_extensions_Thread_start( the_thread ); |
---|
49 | |
---|
50 | _Thread_Dispatch_enable( cpu_self ); |
---|
51 | return true; |
---|
52 | } |
---|