source: rtems/cpukit/rtems/src/signal.c @ ea9d7db

4.104.114.84.95
Last change on this file since ea9d7db was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  Signal Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/asr.h>
18#include <rtems/isr.h>
19#include <rtems/modes.h>
20#include <rtems/signal.h>
21#include <rtems/thread.h>
22
23/*PAGE
24 *
25 *  rtems_signal_catch
26 *
27 *  This directive allows a thread to specify what action to take when
28 *  catching signals.
29 *
30 *  Input parameters:
31 *    handler  - address of asynchronous signal routine (asr)
32 *              ( NULL indicates asr is invalid )
33 *    mode_set - mode value for asr
34 *
35 *  Output parameters:
36 *    RTEMS_SUCCESSFUL - always succeeds
37 */
38
39rtems_status_code rtems_signal_catch(
40  rtems_asr_entry   handler,
41  rtems_mode mode_set
42)
43{
44  Thread_Control *executing;
45
46  executing = _Thread_Executing;
47  _Thread_Disable_dispatch(); /* cannot reschedule while */
48                              /*   the thread is inconsistent */
49
50  if ( ! _ASR_Is_null_handler( handler ) ) {
51    executing->Signal.mode_set = mode_set;
52    executing->Signal.handler  = handler;
53  }
54  else
55    _ASR_Initialize( &executing->Signal );
56  _Thread_Enable_dispatch();
57  return( RTEMS_SUCCESSFUL );
58}
59
60/*PAGE
61 *
62 *  rtems_signal_send
63 *
64 *  This directive allows a thread to send signals to a thread.
65 *
66 *  Input parameters:
67 *    id         - thread id
68 *    signal_set - signal set
69 *
70 *  Output parameters:
71 *    RTEMS_SUCCESSFUL - if successful
72 *    error code - if unsuccessful
73 */
74
75rtems_status_code rtems_signal_send(
76  Objects_Id             id,
77  rtems_signal_set signal_set
78)
79{
80  register Thread_Control *the_thread;
81  Objects_Locations        location;
82
83  the_thread = _Thread_Get( id, &location );
84  switch ( location ) {
85    case OBJECTS_ERROR:
86      return( RTEMS_INVALID_ID );
87    case OBJECTS_REMOTE:
88      return _Signal_MP_Send_request_packet(
89        SIGNAL_MP_SEND_REQUEST,
90        id,
91        signal_set
92      );
93    case OBJECTS_LOCAL:
94      if ( ! _ASR_Is_null_handler( the_thread->Signal.handler ) ) {
95        if ( _Modes_Is_asr_disabled( the_thread->current_modes ) )
96          _ASR_Post_signals( signal_set, &the_thread->Signal.signals_pending );
97        else {
98          _ASR_Post_signals( signal_set, &the_thread->Signal.signals_posted );
99          if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
100            _ISR_Signals_to_thread_executing = TRUE;
101        }
102        _Thread_Enable_dispatch();
103        return( RTEMS_SUCCESSFUL );
104      }
105      _Thread_Enable_dispatch();
106      return( RTEMS_NOT_DEFINED );
107  }
108
109  return( RTEMS_INTERNAL_ERROR );   /* unreached - only to remove warnings */
110}
Note: See TracBrowser for help on using the repository browser.