RTEMS
eventreceive.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-1999.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include <rtems/rtems/eventimpl.h>
23 #include <rtems/rtems/tasksdata.h>
24 #include <rtems/score/statesimpl.h>
25 #include <rtems/score/threadimpl.h>
26 
28  rtems_event_set event_in,
29  rtems_option option_set,
30  rtems_interval ticks,
31  rtems_event_set *event_out
32 )
33 {
35 
36  if ( event_out != NULL ) {
37  ISR_lock_Context lock_context;
38  Thread_Control *executing;
39  RTEMS_API_Control *api;
40  Event_Control *event;
41 
42  executing = _Thread_Wait_acquire_default_for_executing( &lock_context );
43  api = executing->API_Extensions[ THREAD_API_RTEMS ];
44  event = &api->Event;
45 
46  if ( !_Event_sets_Is_empty( event_in ) ) {
47  sc = _Event_Seize(
48  event_in,
49  option_set,
50  ticks,
51  event_out,
52  executing,
53  event,
56  &lock_context
57  );
58  } else {
59  *event_out = event->pending_events;
60  _Thread_Wait_release_default( executing, &lock_context );
61  sc = RTEMS_SUCCESSFUL;
62  }
63  } else {
65  }
66 
67  return sc;
68 }
uint32_t rtems_option
This type is used to represent an option set.
Definition: options.h:121
static __inline__ Thread_Control * _Thread_Wait_acquire_default_for_executing(ISR_lock_Context *lock_context)
Acquires the thread wait default lock and returns the executing thread.
Definition: threadimpl.h:1677
Event_Control Event
Definition: tasksdata.h:43
Classic Event Manager Implementation.
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
Inlined Routines Associated with Thread State Information.
This status code indicates that a specified address was invalid.
Definition: status.h:133
void * API_Extensions[THREAD_API_LAST+1]
Definition: thread.h:840
Watchdog_Interval rtems_interval
This type is used to represent clock tick intervals.
Definition: types.h:90
rtems_status_code rtems_event_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives or gets an event set.
Definition: eventreceive.c:27
static __inline__ bool _Event_sets_Is_empty(rtems_event_set the_event_set)
Checks if on events are posted in the event_set.
Definition: eventimpl.h:86
Inlined Routines from the Thread Handler.
#define STATES_WAITING_FOR_EVENT
Definition: statesimpl.h:54
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
uint32_t rtems_event_set
This integer type can hold an event set of up to 32 events represented as a bit field.
Definition: event.h:94
#define THREAD_WAIT_CLASS_EVENT
Indicates that the thread waits for an event.
Definition: threadimpl.h:2173
static __inline__ void _Thread_Wait_release_default(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the thread wait default lock and restores the previous interrupt status. ...
Definition: threadimpl.h:1734
Classic Tasks Manager Data Structures.