[0123e3b] | 1 | /* |
---|
| 2 | * Signal Manager |
---|
| 3 | * |
---|
| 4 | * |
---|
[0e87deaa] | 5 | * COPYRIGHT (c) 1989-2007. |
---|
[0123e3b] | 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 |
---|
[277cc95] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[0123e3b] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
[1095ec1] | 15 | #if HAVE_CONFIG_H |
---|
| 16 | #include "config.h" |
---|
| 17 | #endif |
---|
| 18 | |
---|
[0123e3b] | 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 |
---|
[69d2e69] | 40 | * error code - if unsuccessful |
---|
[0123e3b] | 41 | */ |
---|
| 42 | |
---|
| 43 | rtems_status_code rtems_signal_send( |
---|
[69d2e69] | 44 | Objects_Id id, |
---|
| 45 | rtems_signal_set signal_set |
---|
[0123e3b] | 46 | ) |
---|
| 47 | { |
---|
| 48 | register Thread_Control *the_thread; |
---|
| 49 | Objects_Locations location; |
---|
| 50 | RTEMS_API_Control *api; |
---|
| 51 | ASR_Information *asr; |
---|
| 52 | |
---|
[69d2e69] | 53 | if ( !signal_set ) |
---|
| 54 | return RTEMS_INVALID_NUMBER; |
---|
| 55 | |
---|
[0123e3b] | 56 | the_thread = _Thread_Get( id, &location ); |
---|
| 57 | switch ( location ) { |
---|
| 58 | |
---|
| 59 | case OBJECTS_LOCAL: |
---|
| 60 | api = the_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
| 61 | asr = &api->Signal; |
---|
| 62 | |
---|
| 63 | if ( ! _ASR_Is_null_handler( asr->handler ) ) { |
---|
| 64 | if ( asr->is_enabled ) { |
---|
| 65 | _ASR_Post_signals( signal_set, &asr->signals_posted ); |
---|
| 66 | |
---|
[484a769] | 67 | the_thread->do_post_task_switch_extension = true; |
---|
[0123e3b] | 68 | |
---|
| 69 | if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) ) |
---|
[eaef4657] | 70 | _ISR_Signals_to_thread_executing = true; |
---|
[0123e3b] | 71 | } else { |
---|
| 72 | _ASR_Post_signals( signal_set, &asr->signals_pending ); |
---|
| 73 | } |
---|
| 74 | _Thread_Enable_dispatch(); |
---|
| 75 | return RTEMS_SUCCESSFUL; |
---|
| 76 | } |
---|
| 77 | _Thread_Enable_dispatch(); |
---|
| 78 | return RTEMS_NOT_DEFINED; |
---|
[ebe61382] | 79 | |
---|
| 80 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 81 | case OBJECTS_REMOTE: |
---|
| 82 | return _Signal_MP_Send_request_packet( |
---|
| 83 | SIGNAL_MP_SEND_REQUEST, |
---|
| 84 | id, |
---|
| 85 | signal_set |
---|
| 86 | ); |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | case OBJECTS_ERROR: |
---|
| 90 | break; |
---|
[0123e3b] | 91 | } |
---|
| 92 | |
---|
[ebe61382] | 93 | return RTEMS_INVALID_ID; |
---|
[0123e3b] | 94 | } |
---|