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/schedulerimpl.h> |
---|
25 | #include <rtems/score/userextimpl.h> |
---|
26 | |
---|
27 | bool _Thread_Start( |
---|
28 | Thread_Control *the_thread, |
---|
29 | Thread_Start_types the_prototype, |
---|
30 | void *entry_point, |
---|
31 | void *pointer_argument, |
---|
32 | Thread_Entry_numeric_type numeric_argument, |
---|
33 | Per_CPU_Control *cpu |
---|
34 | ) |
---|
35 | { |
---|
36 | if ( _States_Is_dormant( the_thread->current_state ) ) { |
---|
37 | |
---|
38 | the_thread->Start.entry_point = (Thread_Entry) entry_point; |
---|
39 | |
---|
40 | the_thread->Start.prototype = the_prototype; |
---|
41 | the_thread->Start.pointer_argument = pointer_argument; |
---|
42 | the_thread->Start.numeric_argument = numeric_argument; |
---|
43 | |
---|
44 | _Thread_Load_environment( the_thread ); |
---|
45 | |
---|
46 | if ( cpu == NULL ) { |
---|
47 | _Thread_Ready( the_thread ); |
---|
48 | } else { |
---|
49 | const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu ); |
---|
50 | |
---|
51 | if ( scheduler != NULL ) { |
---|
52 | the_thread->current_state = STATES_READY; |
---|
53 | _Scheduler_Start_idle( scheduler, the_thread, cpu ); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | _User_extensions_Thread_start( the_thread ); |
---|
58 | |
---|
59 | return true; |
---|
60 | } |
---|
61 | |
---|
62 | return false; |
---|
63 | } |
---|