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/score/threadimpl.h> |
---|
25 | |
---|
26 | rtems_status_code rtems_task_restart( |
---|
27 | rtems_id id, |
---|
28 | rtems_task_argument argument |
---|
29 | ) |
---|
30 | { |
---|
31 | Thread_Control *the_thread; |
---|
32 | ISR_lock_Context lock_context; |
---|
33 | Thread_Entry_information entry; |
---|
34 | bool ok; |
---|
35 | |
---|
36 | the_thread = _Thread_Get( id, &lock_context ); |
---|
37 | |
---|
38 | if ( the_thread == NULL ) { |
---|
39 | #if defined(RTEMS_MULTIPROCESSING) |
---|
40 | if ( _Thread_MP_Is_remote( id ) ) { |
---|
41 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
42 | } |
---|
43 | #endif |
---|
44 | |
---|
45 | return RTEMS_INVALID_ID; |
---|
46 | } |
---|
47 | |
---|
48 | entry = the_thread->Start.Entry; |
---|
49 | entry.Kinds.Numeric.argument = argument; |
---|
50 | |
---|
51 | if ( the_thread == _Thread_Executing ) { |
---|
52 | _Thread_Restart_self( the_thread, &entry, &lock_context ); |
---|
53 | RTEMS_UNREACHABLE(); |
---|
54 | } |
---|
55 | |
---|
56 | ok = _Thread_Restart_other( the_thread, &entry, &lock_context ); |
---|
57 | |
---|
58 | return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE; |
---|
59 | } |
---|