1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Send Signal |
---|
5 | * @ingroup ClassicSignal |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/rtems/asr.h> |
---|
24 | #include <rtems/score/isr.h> |
---|
25 | #include <rtems/rtems/modes.h> |
---|
26 | #include <rtems/rtems/signal.h> |
---|
27 | #include <rtems/score/thread.h> |
---|
28 | #include <rtems/rtems/tasks.h> |
---|
29 | |
---|
30 | rtems_status_code rtems_signal_send( |
---|
31 | rtems_id id, |
---|
32 | rtems_signal_set signal_set |
---|
33 | ) |
---|
34 | { |
---|
35 | register Thread_Control *the_thread; |
---|
36 | Objects_Locations location; |
---|
37 | RTEMS_API_Control *api; |
---|
38 | ASR_Information *asr; |
---|
39 | |
---|
40 | if ( !signal_set ) |
---|
41 | return RTEMS_INVALID_NUMBER; |
---|
42 | |
---|
43 | the_thread = _Thread_Get( id, &location ); |
---|
44 | switch ( location ) { |
---|
45 | |
---|
46 | case OBJECTS_LOCAL: |
---|
47 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
48 | asr = &api->Signal; |
---|
49 | |
---|
50 | if ( ! _ASR_Is_null_handler( asr->handler ) ) { |
---|
51 | if ( asr->is_enabled ) { |
---|
52 | _ASR_Post_signals( signal_set, &asr->signals_posted ); |
---|
53 | |
---|
54 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
---|
55 | _Thread_Dispatch_necessary = true; |
---|
56 | } else { |
---|
57 | _ASR_Post_signals( signal_set, &asr->signals_pending ); |
---|
58 | } |
---|
59 | _Thread_Enable_dispatch(); |
---|
60 | return RTEMS_SUCCESSFUL; |
---|
61 | } |
---|
62 | _Thread_Enable_dispatch(); |
---|
63 | return RTEMS_NOT_DEFINED; |
---|
64 | |
---|
65 | #if defined(RTEMS_MULTIPROCESSING) |
---|
66 | case OBJECTS_REMOTE: |
---|
67 | return _Signal_MP_Send_request_packet( |
---|
68 | SIGNAL_MP_SEND_REQUEST, |
---|
69 | id, |
---|
70 | signal_set |
---|
71 | ); |
---|
72 | #endif |
---|
73 | |
---|
74 | case OBJECTS_ERROR: |
---|
75 | break; |
---|
76 | } |
---|
77 | |
---|
78 | return RTEMS_INVALID_ID; |
---|
79 | } |
---|