source: rtems/cpukit/posix/src/psignalclearsignals.c @ 77fbbd6

5
Last change on this file since 77fbbd6 was 93306058, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 12:43:19

score: _CORE_mutex_Check_dispatch_for_seize()

Move the safety check performed by
_CORE_mutex_Check_dispatch_for_seize() out of the performance critical
path and generalize it. Blocking on a thread queue with an unexpected
thread dispatch disabled level is illegal in all system states.

Add the expected thread dispatch disable level (which may be 1 or 2
depending on the operation) to Thread_queue_Context and use it in
_Thread_queue_Enqueue_critical().

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Signals Clear Signals
5 * @ingroup POSIX_SIGNALS POSIX Signals Support
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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 <errno.h>
22#include <pthread.h>
23#include <signal.h>
24
25#include <rtems/system.h>
26#include <rtems/score/isr.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/seterr.h>
30#include <rtems/posix/threadsup.h>
31#include <rtems/posix/psignalimpl.h>
32#include <rtems/posix/pthreadimpl.h>
33#include <stdio.h>
34
35/*
36 *  _POSIX_signals_Clear_signals
37 */
38
39bool _POSIX_signals_Clear_signals(
40  POSIX_API_Control  *api,
41  int                 signo,
42  siginfo_t          *info,
43  bool                is_global,
44  bool                check_blocked,
45  bool                do_signals_acquire_release
46)
47{
48  sigset_t                    mask;
49  sigset_t                    signals_unblocked;
50  Thread_queue_Context        queue_context;
51  bool                        do_callout;
52  POSIX_signals_Siginfo_node *psiginfo;
53
54  mask = signo_to_mask( signo );
55
56  do_callout = false;
57
58  /* set blocked signals based on if checking for them, SIGNAL_ALL_MASK
59   * insures that no signals are blocked and all are checked.
60   */
61
62  if ( check_blocked )
63    signals_unblocked = api->signals_unblocked;
64  else
65    signals_unblocked = SIGNAL_ALL_MASK;
66
67  /* XXX is this right for siginfo type signals? */
68  /* XXX are we sure they can be cleared the same way? */
69
70  if ( do_signals_acquire_release ) {
71    _Thread_queue_Context_initialize( &queue_context );
72    _POSIX_signals_Acquire( &queue_context );
73  }
74
75    if ( is_global ) {
76       if ( mask & (_POSIX_signals_Pending & signals_unblocked) ) {
77         if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
78           psiginfo = (POSIX_signals_Siginfo_node *)
79             _Chain_Get_unprotected( &_POSIX_signals_Siginfo[ signo ] );
80           _POSIX_signals_Clear_process_signals( signo );
81           /*
82            *  It may be impossible to get here with an empty chain
83            *  BUT until that is proven we need to be defensive and
84            *  protect against it.
85            */
86           if ( psiginfo ) {
87             *info = psiginfo->Info;
88             _Chain_Append_unprotected(
89               &_POSIX_signals_Inactive_siginfo,
90               &psiginfo->Node
91             );
92           } else
93             do_callout = false;
94         }
95         _POSIX_signals_Clear_process_signals( signo );
96         do_callout = true;
97       }
98    } else {
99      if ( mask & (api->signals_pending & signals_unblocked) ) {
100        api->signals_pending &= ~mask;
101        do_callout = true;
102      }
103    }
104
105  if ( do_signals_acquire_release ) {
106    _POSIX_signals_Release( &queue_context );
107  }
108
109  return do_callout;
110}
Note: See TracBrowser for help on using the repository browser.