1 | /* |
---|
2 | * Signal 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/asr.h> |
---|
22 | #include <rtems/score/isr.h> |
---|
23 | #include <rtems/rtems/modes.h> |
---|
24 | #include <rtems/rtems/signal.h> |
---|
25 | #include <rtems/score/thread.h> |
---|
26 | #include <rtems/rtems/tasks.h> |
---|
27 | |
---|
28 | /*PAGE |
---|
29 | * |
---|
30 | * rtems_signal_send |
---|
31 | * |
---|
32 | * This directive allows a thread to send signals to a thread. |
---|
33 | * |
---|
34 | * Input parameters: |
---|
35 | * id - thread id |
---|
36 | * signal_set - signal set |
---|
37 | * |
---|
38 | * Output parameters: |
---|
39 | * RTEMS_SUCCESSFUL - if successful |
---|
40 | * error code - if unsuccessful |
---|
41 | */ |
---|
42 | |
---|
43 | rtems_status_code rtems_signal_send( |
---|
44 | Objects_Id id, |
---|
45 | rtems_signal_set signal_set |
---|
46 | ) |
---|
47 | { |
---|
48 | register Thread_Control *the_thread; |
---|
49 | Objects_Locations location; |
---|
50 | RTEMS_API_Control *api; |
---|
51 | ASR_Information *asr; |
---|
52 | |
---|
53 | if ( !signal_set ) |
---|
54 | return RTEMS_INVALID_NUMBER; |
---|
55 | |
---|
56 | the_thread = _Thread_Get( id, &location ); |
---|
57 | switch ( location ) { |
---|
58 | |
---|
59 | case OBJECTS_REMOTE: |
---|
60 | #if defined(RTEMS_MULTIPROCESSING) |
---|
61 | return _Signal_MP_Send_request_packet( |
---|
62 | SIGNAL_MP_SEND_REQUEST, |
---|
63 | id, |
---|
64 | signal_set |
---|
65 | ); |
---|
66 | #endif |
---|
67 | |
---|
68 | case OBJECTS_ERROR: |
---|
69 | return RTEMS_INVALID_ID; |
---|
70 | |
---|
71 | case OBJECTS_LOCAL: |
---|
72 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
73 | asr = &api->Signal; |
---|
74 | |
---|
75 | if ( ! _ASR_Is_null_handler( asr->handler ) ) { |
---|
76 | if ( asr->is_enabled ) { |
---|
77 | _ASR_Post_signals( signal_set, &asr->signals_posted ); |
---|
78 | |
---|
79 | the_thread->do_post_task_switch_extension = TRUE; |
---|
80 | |
---|
81 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
---|
82 | _ISR_Signals_to_thread_executing = TRUE; |
---|
83 | } else { |
---|
84 | _ASR_Post_signals( signal_set, &asr->signals_pending ); |
---|
85 | } |
---|
86 | _Thread_Enable_dispatch(); |
---|
87 | return RTEMS_SUCCESSFUL; |
---|
88 | } |
---|
89 | _Thread_Enable_dispatch(); |
---|
90 | return RTEMS_NOT_DEFINED; |
---|
91 | } |
---|
92 | |
---|
93 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
94 | } |
---|