source: rtems/cpukit/rtems/src/signalcatch.c @ bb2ad039

5
Last change on this file since bb2ad039 was bb2ad039, checked in by Sebastian Huber <sebastian.huber@…>, on 05/04/16 at 08:09:45

rtems: Avoid Giant lock for signals

Update #2555.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Catch Signal
5 *  @ingroup ClassicSignal
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/sysinit.h>
22#include <rtems/rtems/signalimpl.h>
23#include <rtems/rtems/asrimpl.h>
24#include <rtems/rtems/tasks.h>
25#include <rtems/score/threadimpl.h>
26
27void _Signal_Action_handler(
28  Thread_Control  *executing,
29  Thread_Action   *action,
30  Per_CPU_Control *cpu,
31  ISR_Level        level
32)
33{
34  RTEMS_API_Control *api;
35  ASR_Information   *asr;
36  rtems_signal_set   signal_set;
37  Modes_Control      prev_mode;
38
39  (void) action;
40  _Thread_Action_release_and_ISR_enable( cpu, level );
41
42  api = executing->API_Extensions[ THREAD_API_RTEMS ];
43  if ( !api )
44    return;
45
46  /*
47   *  Signal Processing
48   */
49
50  asr = &api->Signal;
51  signal_set = _ASR_Get_posted_signals( asr );
52
53  if ( signal_set == 0 ) {
54    return;
55  }
56
57  asr->nest_level += 1;
58  rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode );
59
60  (*asr->handler)( signal_set );
61
62  asr->nest_level -= 1;
63  rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
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  ISR_lock_Context    lock_context;
75
76  _ISR_lock_ISR_disable( &lock_context );
77  executing = _Thread_Executing;
78  api = executing->API_Extensions[ THREAD_API_RTEMS ];
79  asr = &api->Signal;
80
81  _ASR_Acquire_critical( asr, &lock_context );
82
83  if ( !_ASR_Is_null_handler( asr_handler ) ) {
84    asr->mode_set = mode_set;
85    asr->handler = asr_handler;
86  } else {
87    _ASR_Initialize( asr );
88  }
89
90  _ASR_Release( asr, &lock_context );
91  return RTEMS_SUCCESSFUL;
92}
93
94#if defined(RTEMS_MULTIPROCESSING)
95static void _Signal_Manager_initialization( void )
96{
97  _MPCI_Register_packet_processor(
98    MP_PACKET_SIGNAL,
99    _Signal_MP_Process_packet
100  );
101}
102
103RTEMS_SYSINIT_ITEM(
104  _Signal_Manager_initialization,
105  RTEMS_SYSINIT_CLASSIC_SIGNAL,
106  RTEMS_SYSINIT_ORDER_MIDDLE
107);
108#endif
Note: See TracBrowser for help on using the repository browser.