source: rtems/cpukit/rtems/src/eventseize.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  Event Manager
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/rtems/status.h>
18#include <rtems/rtems/event.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/object.h>
21#include <rtems/rtems/options.h>
22#include <rtems/score/states.h>
23#include <rtems/score/thread.h>
24#include <rtems/rtems/tasks.h>
25
26/*
27 *  _Event_Seize
28 *
29 *  This routine attempts to satisfy the requested event condition
30 *  for the running thread.
31 *
32 *  Input parameters:
33 *    event_in   - the event condition to satisfy
34 *    option_set - acquire event options
35 *    ticks      - interval to wait
36 *    event_out  - pointer to event set output area
37 *
38 *  Output parameters: NONE
39 *    *event_out - event set output area filled in
40 *
41 *  INTERRUPT LATENCY:
42 *    available
43 *    wait
44 *    check sync
45 */
46
47void _Event_Seize(
48  rtems_event_set  event_in,
49  rtems_option     option_set,
50  rtems_interval   ticks,
51  rtems_event_set *event_out
52)
53{
54  Thread_Control                   *executing;
55  rtems_event_set                   seized_events;
56  rtems_event_set                   pending_events;
57  ISR_Level                         level;
58  RTEMS_API_Control                *api;
59  Thread_blocking_operation_States  sync_state;
60
61  executing = _Thread_Executing;
62  executing->Wait.return_code = RTEMS_SUCCESSFUL;
63
64  api = executing->API_Extensions[ THREAD_API_RTEMS ];
65
66  _ISR_Disable( level );
67  pending_events = api->pending_events;
68  seized_events  = _Event_sets_Get( pending_events, event_in );
69
70  if ( !_Event_sets_Is_empty( seized_events ) &&
71       (seized_events == event_in || _Options_Is_any( option_set )) ) {
72    api->pending_events =
73      _Event_sets_Clear( pending_events, seized_events );
74    _ISR_Enable( level );
75    *event_out = seized_events;
76    return;
77  }
78
79  if ( _Options_Is_no_wait( option_set ) ) {
80    _ISR_Enable( level );
81    executing->Wait.return_code = RTEMS_UNSATISFIED;
82    *event_out = seized_events;
83    return;
84  }
85
86  /*
87   *  Note what we are waiting for BEFORE we enter the critical section.
88   *  The interrupt critical section management code needs this to be
89   *  set properly when we are marked as in the event critical section.
90   *
91   *  NOTE: Since interrupts are disabled, this isn't that much of an
92   *        issue but better safe than sorry.
93   */
94  executing->Wait.option            = (uint32_t) option_set;
95  executing->Wait.count             = (uint32_t) event_in;
96  executing->Wait.return_argument   = event_out;
97
98  _Event_Sync_state = THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
99
100  _ISR_Enable( level );
101
102  if ( ticks ) {
103    _Watchdog_Initialize(
104      &executing->Timer,
105      _Event_Timeout,
106      executing->Object.id,
107      NULL
108    );
109    _Watchdog_Insert_ticks( &executing->Timer, ticks );
110  }
111
112  _Thread_Set_state( executing, STATES_WAITING_FOR_EVENT );
113
114  _ISR_Disable( level );
115
116  sync_state = _Event_Sync_state;
117  _Event_Sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
118  if ( sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
119    _ISR_Enable( level );
120    return;
121  }
122
123  /*
124   *  An interrupt completed the thread's blocking request.
125   *  The blocking thread was satisfied by an ISR or timed out.
126   *
127   *  WARNING! Entering with interrupts disabled and returning with interrupts
128   *  enabled!
129   */
130  _Thread_blocking_operation_Cancel( sync_state, executing, level );
131}
Note: See TracBrowser for help on using the repository browser.