1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSImplClassicTask |
---|
5 | * |
---|
6 | * @brief This source file contains the implementation of |
---|
7 | * rtems_task_restart(). |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2014. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifdef HAVE_CONFIG_H |
---|
20 | #include "config.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #include <rtems/rtems/tasks.h> |
---|
24 | #include <rtems/rtems/statusimpl.h> |
---|
25 | #include <rtems/score/threadimpl.h> |
---|
26 | |
---|
27 | rtems_status_code rtems_task_restart( |
---|
28 | rtems_id id, |
---|
29 | rtems_task_argument argument |
---|
30 | ) |
---|
31 | { |
---|
32 | Thread_Control *the_thread; |
---|
33 | ISR_lock_Context lock_context; |
---|
34 | Thread_Entry_information entry; |
---|
35 | Status_Control status; |
---|
36 | |
---|
37 | the_thread = _Thread_Get( id, &lock_context ); |
---|
38 | |
---|
39 | if ( the_thread == NULL ) { |
---|
40 | #if defined(RTEMS_MULTIPROCESSING) |
---|
41 | if ( _Thread_MP_Is_remote( id ) ) { |
---|
42 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
43 | } |
---|
44 | #endif |
---|
45 | |
---|
46 | return RTEMS_INVALID_ID; |
---|
47 | } |
---|
48 | |
---|
49 | entry = the_thread->Start.Entry; |
---|
50 | entry.Kinds.Numeric.argument = argument; |
---|
51 | |
---|
52 | if ( the_thread == _Thread_Executing ) { |
---|
53 | _Thread_Restart_self( the_thread, &entry, &lock_context ); |
---|
54 | RTEMS_UNREACHABLE(); |
---|
55 | } |
---|
56 | |
---|
57 | status = _Thread_Restart_other( the_thread, &entry, &lock_context ); |
---|
58 | |
---|
59 | return _Status_Get( status ); |
---|
60 | } |
---|