1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Restart Thread |
---|
5 | * @ingroup ScoreThread |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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 | #include <rtems/score/threadqimpl.h> |
---|
23 | #include <rtems/score/userextimpl.h> |
---|
24 | #include <rtems/score/watchdogimpl.h> |
---|
25 | |
---|
26 | void _Thread_Life_action_handler( |
---|
27 | Thread_Control *executing, |
---|
28 | Thread_Action *action, |
---|
29 | Per_CPU_Control *cpu, |
---|
30 | ISR_Level level |
---|
31 | ) |
---|
32 | { |
---|
33 | (void) action; |
---|
34 | _Thread_Action_release_and_ISR_enable( cpu, level ); |
---|
35 | |
---|
36 | _User_extensions_Thread_restart( the_thread ); |
---|
37 | |
---|
38 | _Thread_Disable_dispatch(); |
---|
39 | |
---|
40 | _Thread_Load_environment( executing ); |
---|
41 | _Thread_Restart_self( executing ); |
---|
42 | } |
---|
43 | |
---|
44 | static void _Thread_Start_life_change( |
---|
45 | Thread_Control *the_thread, |
---|
46 | Priority_Control priority |
---|
47 | ) |
---|
48 | { |
---|
49 | the_thread->resource_count = 0; |
---|
50 | the_thread->is_preemptible = the_thread->Start.is_preemptible; |
---|
51 | the_thread->budget_algorithm = the_thread->Start.budget_algorithm; |
---|
52 | the_thread->budget_callout = the_thread->Start.budget_callout; |
---|
53 | the_thread->real_priority = priority; |
---|
54 | |
---|
55 | _Thread_Set_transient( the_thread ); |
---|
56 | _Thread_queue_Extract_with_proxy( the_thread ); |
---|
57 | _Watchdog_Remove( &the_thread->Timer ); |
---|
58 | _Thread_Set_priority( the_thread, priority ); |
---|
59 | _Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action ); |
---|
60 | _Thread_Ready( the_thread ); |
---|
61 | _Thread_Request_dispatch_if_executing( the_thread ); |
---|
62 | } |
---|
63 | |
---|
64 | static void _Thread_Request_life_change( |
---|
65 | Thread_Control *the_thread, |
---|
66 | Thread_Control *executing, |
---|
67 | Priority_Control priority |
---|
68 | ) |
---|
69 | { |
---|
70 | _Thread_Start_life_change( the_thread, priority ); |
---|
71 | } |
---|
72 | |
---|
73 | bool _Thread_Restart( |
---|
74 | Thread_Control *the_thread, |
---|
75 | Thread_Control *executing, |
---|
76 | void *pointer_argument, |
---|
77 | Thread_Entry_numeric_type numeric_argument |
---|
78 | ) |
---|
79 | { |
---|
80 | if ( !_States_Is_dormant( the_thread->current_state ) ) { |
---|
81 | the_thread->Start.pointer_argument = pointer_argument; |
---|
82 | the_thread->Start.numeric_argument = numeric_argument; |
---|
83 | |
---|
84 | _Thread_Request_life_change( |
---|
85 | the_thread, |
---|
86 | executing, |
---|
87 | the_thread->Start.initial_priority |
---|
88 | ); |
---|
89 | |
---|
90 | return true; |
---|
91 | } |
---|
92 | |
---|
93 | return false; |
---|
94 | } |
---|