source: rtems/c/src/exec/rtems/src/signal.c @ 97e2729d

4.104.114.84.95
Last change on this file since 97e2729d was 97e2729d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 17:38:09

Added --disable-multiprocessing flag and modified a lot of files to make
it work.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  Signal Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
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#if defined(RTEMS_MULTIPROCESSING)
43  _MPCI_Register_packet_processor(
44    MP_PACKET_SIGNAL,
45    _Signal_MP_Process_packet
46  );
47#endif
48}
49 
50/*PAGE
51 *
52 *  rtems_signal_catch
53 *
54 *  This directive allows a thread to specify what action to take when
55 *  catching signals.
56 *
57 *  Input parameters:
58 *    handler  - address of asynchronous signal routine (asr)
59 *              ( NULL indicates asr is invalid )
60 *    mode_set - mode value for asr
61 *
62 *  Output parameters:
63 *    RTEMS_SUCCESSFUL - always succeeds
64 */
65
66rtems_status_code rtems_signal_catch(
67  rtems_asr_entry   asr_handler,
68  rtems_mode        mode_set
69)
70{
71  Thread_Control     *executing;
72  RTEMS_API_Control  *api;
73  ASR_Information    *asr;
74
75/* XXX normalize mode */
76  executing = _Thread_Executing;
77  api = executing->API_Extensions[ THREAD_API_RTEMS ];
78  asr = &api->Signal;
79
80  _Thread_Disable_dispatch(); /* cannot reschedule while */
81                              /*   the thread is inconsistent */
82
83  if ( !_ASR_Is_null_handler( asr_handler ) ) {
84    asr->mode_set = mode_set;
85    asr->handler = asr_handler;
86  }
87  else
88    _ASR_Initialize( asr );
89  _Thread_Enable_dispatch();
90  return RTEMS_SUCCESSFUL;
91}
92
93/*PAGE
94 *
95 *  rtems_signal_send
96 *
97 *  This directive allows a thread to send signals to a thread.
98 *
99 *  Input parameters:
100 *    id         - thread id
101 *    signal_set - signal set
102 *
103 *  Output parameters:
104 *    RTEMS_SUCCESSFUL - if successful
105 *    error code - if unsuccessful
106 */
107
108rtems_status_code rtems_signal_send(
109  Objects_Id             id,
110  rtems_signal_set signal_set
111)
112{
113  register Thread_Control *the_thread;
114  Objects_Locations        location;
115  RTEMS_API_Control       *api;
116  ASR_Information         *asr;
117
118  the_thread = _Thread_Get( id, &location );
119  switch ( location ) {
120
121    case OBJECTS_REMOTE:
122#if defined(RTEMS_MULTIPROCESSING)
123      return _Signal_MP_Send_request_packet(
124        SIGNAL_MP_SEND_REQUEST,
125        id,
126        signal_set
127      );
128#endif
129
130    case OBJECTS_ERROR:
131      return RTEMS_INVALID_ID;
132
133    case OBJECTS_LOCAL:
134      api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
135      asr = &api->Signal;
136
137      if ( ! _ASR_Is_null_handler( asr->handler ) ) {
138        if ( asr->is_enabled ) {
139          _ASR_Post_signals( signal_set, &asr->signals_posted );
140
141          the_thread->do_post_task_switch_extension = TRUE;
142
143          if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
144            _ISR_Signals_to_thread_executing = TRUE;
145        } else {
146          _ASR_Post_signals( signal_set, &asr->signals_pending );
147        }
148        _Thread_Enable_dispatch();
149        return RTEMS_SUCCESSFUL;
150      }
151      _Thread_Enable_dispatch();
152      return RTEMS_NOT_DEFINED;
153  }
154
155  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
156}
Note: See TracBrowser for help on using the repository browser.