source: rtems/cpukit/rtems/src/signal.c @ 8bdcfc4

4.104.114.84.95
Last change on this file since 8bdcfc4 was 5e9b32b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/26/95 at 19:27:15

posix support initially added

  • Property mode set to 100644
File size: 3.5 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/rtems/status.h>
18#include <rtems/rtems/asr.h>
19#include <rtems/score/isr.h>
20#include <rtems/rtems/modes.h>
21#include <rtems/rtems/signal.h>
22#include <rtems/score/thread.h>
23#include <rtems/rtems/tasks.h>
24
25/*PAGE
26 *
27 *  _Signal_Manager_initialization
28 *
29 *  This routine initializes all signal manager related data structures.
30 *
31 *  Input parameters:   NONE
32 *
33 *  Output parameters:  NONE
34 */
35 
36void _Signal_Manager_initialization( void )
37{
38  /*
39   *  Register the MP Process Packet routine.
40   */
41 
42  _MPCI_Register_packet_processor(
43    MP_PACKET_SIGNAL,
44    _Signal_MP_Process_packet
45  );
46}
47 
48/*PAGE
49 *
50 *  rtems_signal_catch
51 *
52 *  This directive allows a thread to specify what action to take when
53 *  catching signals.
54 *
55 *  Input parameters:
56 *    handler  - address of asynchronous signal routine (asr)
57 *              ( NULL indicates asr is invalid )
58 *    mode_set - mode value for asr
59 *
60 *  Output parameters:
61 *    RTEMS_SUCCESSFUL - always succeeds
62 */
63
64rtems_status_code rtems_signal_catch(
65  rtems_asr_entry   asr_handler,
66  rtems_mode        mode_set
67)
68{
69  Thread_Control     *executing;
70  RTEMS_API_Control  *api;
71  ASR_Information    *asr;
72
73/* XXX normalize mode */
74  executing = _Thread_Executing;
75  api = executing->API_Extensions[ THREAD_API_RTEMS ];
76  asr = &api->Signal;
77
78  _Thread_Disable_dispatch(); /* cannot reschedule while */
79                              /*   the thread is inconsistent */
80
81  if ( !_ASR_Is_null_handler( asr_handler ) ) {
82    asr->mode_set = mode_set;
83    asr->handler = asr_handler;
84  }
85  else
86    _ASR_Initialize( asr );
87  _Thread_Enable_dispatch();
88  return RTEMS_SUCCESSFUL;
89}
90
91/*PAGE
92 *
93 *  rtems_signal_send
94 *
95 *  This directive allows a thread to send signals to a thread.
96 *
97 *  Input parameters:
98 *    id         - thread id
99 *    signal_set - signal set
100 *
101 *  Output parameters:
102 *    RTEMS_SUCCESSFUL - if successful
103 *    error code - if unsuccessful
104 */
105
106rtems_status_code rtems_signal_send(
107  Objects_Id             id,
108  rtems_signal_set signal_set
109)
110{
111  register Thread_Control *the_thread;
112  Objects_Locations        location;
113  RTEMS_API_Control       *api;
114  ASR_Information         *asr;
115
116  the_thread = _Thread_Get( id, &location );
117  switch ( location ) {
118    case OBJECTS_ERROR:
119      return RTEMS_INVALID_ID;
120    case OBJECTS_REMOTE:
121      return _Signal_MP_Send_request_packet(
122        SIGNAL_MP_SEND_REQUEST,
123        id,
124        signal_set
125      );
126    case OBJECTS_LOCAL:
127      api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
128      asr = &api->Signal;
129
130      if ( ! _ASR_Is_null_handler( asr->handler ) ) {
131        if ( asr->is_enabled ) {
132          _ASR_Post_signals( signal_set, &asr->signals_posted );
133          if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
134            _ISR_Signals_to_thread_executing = TRUE;
135        } else {
136          _ASR_Post_signals( signal_set, &asr->signals_pending );
137        }
138        _Thread_Enable_dispatch();
139        return RTEMS_SUCCESSFUL;
140      }
141      _Thread_Enable_dispatch();
142      return RTEMS_NOT_DEFINED;
143  }
144
145  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
146}
Note: See TracBrowser for help on using the repository browser.