source: rtems/cpukit/rtems/src/signalsend.c @ 6378978

5
Last change on this file since 6378978 was b7af3e44, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 09:57:21

rtems: Move internal structures to tasksdata.h

Update #3598.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Send Signal
5 *  @ingroup ClassicSignal
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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/rtems/signalimpl.h>
22#include <rtems/rtems/asrimpl.h>
23#include <rtems/rtems/tasksdata.h>
24#include <rtems/score/threaddispatch.h>
25#include <rtems/score/threadimpl.h>
26
27rtems_status_code rtems_signal_send(
28  rtems_id          id,
29  rtems_signal_set  signal_set
30)
31{
32  Thread_Control    *the_thread;
33  ISR_lock_Context   lock_context;
34  RTEMS_API_Control *api;
35  ASR_Information   *asr;
36
37  if ( signal_set == 0 ) {
38    return RTEMS_INVALID_NUMBER;
39  }
40
41  the_thread = _Thread_Get( id, &lock_context );
42
43  if ( the_thread == NULL ) {
44#if defined(RTEMS_MULTIPROCESSING)
45    return _Signal_MP_Send( id, signal_set );
46#else
47    return RTEMS_INVALID_ID;
48#endif
49  }
50
51  api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
52  asr = &api->Signal;
53
54  _Thread_State_acquire_critical( the_thread, &lock_context );
55
56  if ( _ASR_Is_null_handler( asr->handler ) ) {
57    _Thread_State_release( the_thread, &lock_context );
58    return RTEMS_NOT_DEFINED;
59  }
60
61  if ( asr->is_enabled ) {
62    Per_CPU_Control *cpu_self;
63
64    _ASR_Post_signals( signal_set, &asr->signals_posted );
65    _Thread_Add_post_switch_action(
66      the_thread,
67      &api->Signal_action,
68      _Signal_Action_handler
69    );
70    cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
71    _Thread_State_release( the_thread, &lock_context );
72    _Thread_Dispatch_enable( cpu_self );
73  } else {
74    _ASR_Post_signals( signal_set, &asr->signals_pending );
75    _Thread_State_release( the_thread, &lock_context );
76  }
77
78  return RTEMS_SUCCESSFUL;
79}
Note: See TracBrowser for help on using the repository browser.