1 | /* |
---|
2 | * RTEMS Task Manager |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/rtems/status.h> |
---|
21 | #include <rtems/rtems/support.h> |
---|
22 | #include <rtems/rtems/modes.h> |
---|
23 | #include <rtems/score/object.h> |
---|
24 | #include <rtems/score/stack.h> |
---|
25 | #include <rtems/score/states.h> |
---|
26 | #include <rtems/rtems/tasks.h> |
---|
27 | #include <rtems/score/thread.h> |
---|
28 | #include <rtems/score/threadq.h> |
---|
29 | #include <rtems/score/tod.h> |
---|
30 | #include <rtems/score/userext.h> |
---|
31 | #include <rtems/score/wkspace.h> |
---|
32 | #include <rtems/score/apiext.h> |
---|
33 | #include <rtems/score/sysstate.h> |
---|
34 | |
---|
35 | /*PAGE |
---|
36 | * |
---|
37 | * rtems_task_is_suspended |
---|
38 | * |
---|
39 | * This directive returns a status indicating whether or not |
---|
40 | * the specified task is suspended. |
---|
41 | * |
---|
42 | * Input parameters: |
---|
43 | * id - thread id |
---|
44 | * |
---|
45 | * Output parameters: |
---|
46 | * RTEMS_SUCCESSFUL - if successful and not suspended |
---|
47 | * RTEMS_ALREADY_SUSPENDED - if successful and suspended |
---|
48 | * error code - if unsuccessful |
---|
49 | */ |
---|
50 | |
---|
51 | rtems_status_code rtems_task_is_suspended( |
---|
52 | Objects_Id id |
---|
53 | ) |
---|
54 | { |
---|
55 | register Thread_Control *the_thread; |
---|
56 | Objects_Locations location; |
---|
57 | |
---|
58 | the_thread = _Thread_Get( id, &location ); |
---|
59 | switch ( location ) { |
---|
60 | |
---|
61 | case OBJECTS_REMOTE: |
---|
62 | |
---|
63 | #if defined(RTEMS_MULTIPROCESSING) |
---|
64 | _Thread_Dispatch(); |
---|
65 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
66 | #endif |
---|
67 | |
---|
68 | case OBJECTS_ERROR: |
---|
69 | return RTEMS_INVALID_ID; |
---|
70 | |
---|
71 | case OBJECTS_LOCAL: |
---|
72 | if ( !_States_Is_suspended( the_thread->current_state ) ) { |
---|
73 | _Thread_Enable_dispatch(); |
---|
74 | return RTEMS_SUCCESSFUL; |
---|
75 | } |
---|
76 | _Thread_Enable_dispatch(); |
---|
77 | return RTEMS_ALREADY_SUSPENDED; |
---|
78 | } |
---|
79 | |
---|
80 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
81 | } |
---|