source: rtems/cpukit/rtems/src/eventseize.c @ 72811c7

Last change on this file since 72811c7 was 72811c7, checked in by Sebastian Huber <sebastian.huber@…>, on 10/14/20 at 08:57:35

rtems: Canonicalize task event file documentation

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicEventImpl
5 *
6 * @brief This source file contains the implementation of
7 *   _Event_Seize() and the task event MPCI support system initialization.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2008.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/sysinit.h>
24#include <rtems/rtems/eventimpl.h>
25#include <rtems/rtems/optionsimpl.h>
26#include <rtems/rtems/statusimpl.h>
27#include <rtems/score/threadimpl.h>
28#include <rtems/score/watchdogimpl.h>
29
30rtems_status_code _Event_Seize(
31  rtems_event_set    event_in,
32  rtems_option       option_set,
33  rtems_interval     ticks,
34  rtems_event_set   *event_out,
35  Thread_Control    *executing,
36  Event_Control     *event,
37  Thread_Wait_flags  wait_class,
38  States_Control     block_state,
39  ISR_lock_Context  *lock_context
40)
41{
42  rtems_event_set    seized_events;
43  rtems_event_set    pending_events;
44  bool               success;
45  Thread_Wait_flags  intend_to_block;
46  Per_CPU_Control   *cpu_self;
47
48  pending_events = event->pending_events;
49  seized_events  = _Event_sets_Get( pending_events, event_in );
50
51  if ( !_Event_sets_Is_empty( seized_events ) &&
52       (seized_events == event_in || _Options_Is_any( option_set )) ) {
53    event->pending_events =
54      _Event_sets_Clear( pending_events, seized_events );
55    _Thread_Wait_release_default( executing, lock_context );
56    *event_out = seized_events;
57    return RTEMS_SUCCESSFUL;
58  }
59
60  if ( _Options_Is_no_wait( option_set ) ) {
61    _Thread_Wait_release_default( executing, lock_context );
62    *event_out = seized_events;
63    return RTEMS_UNSATISFIED;
64  }
65
66  intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
67
68  /*
69   *  Note what we are waiting for BEFORE we enter the critical section.
70   *  The interrupt critical section management code needs this to be
71   *  set properly when we are marked as in the event critical section.
72   *
73   *  NOTE: Since interrupts are disabled, this isn't that much of an
74   *        issue but better safe than sorry.
75   */
76  executing->Wait.return_code     = STATUS_SUCCESSFUL;
77  executing->Wait.option          = option_set;
78  executing->Wait.count           = event_in;
79  executing->Wait.return_argument = event_out;
80  _Thread_Wait_flags_set( executing, intend_to_block );
81
82  cpu_self = _Thread_Dispatch_disable_critical( lock_context );
83  _Thread_Wait_release_default( executing, lock_context );
84
85  if ( ticks ) {
86    _Thread_Add_timeout_ticks( executing, cpu_self, ticks );
87  }
88
89  _Thread_Set_state( executing, block_state );
90
91  success = _Thread_Wait_flags_try_change_acquire(
92    executing,
93    intend_to_block,
94    wait_class | THREAD_WAIT_STATE_BLOCKED
95  );
96  if ( !success ) {
97    _Thread_Timer_remove( executing );
98    _Thread_Unblock( executing );
99  }
100
101  _Thread_Dispatch_direct( cpu_self );
102  return _Status_Get_after_wait( executing );
103}
104
105#if defined(RTEMS_MULTIPROCESSING)
106static void _Event_MP_Initialize( void )
107{
108  _MPCI_Register_packet_processor( MP_PACKET_EVENT, _Event_MP_Process_packet );
109}
110
111RTEMS_SYSINIT_ITEM(
112  _Event_MP_Initialize,
113  RTEMS_SYSINIT_CLASSIC_EVENT_MP,
114  RTEMS_SYSINIT_ORDER_MIDDLE
115);
116#endif
Note: See TracBrowser for help on using the repository browser.