RTEMS
systemeventreceive.c
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Obere Lagerstr. 30
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include <rtems/rtems/eventimpl.h>
28 #include <rtems/rtems/tasksdata.h>
29 #include <rtems/score/statesimpl.h>
30 #include <rtems/score/threadimpl.h>
31 
33  rtems_event_set event_in,
34  rtems_option option_set,
35  rtems_interval ticks,
36  rtems_event_set *event_out
37 )
38 {
40 
41  if ( event_out != NULL ) {
42  ISR_lock_Context lock_context;
43  Thread_Control *executing;
44  RTEMS_API_Control *api;
45  Event_Control *event;
46 
47  executing = _Thread_Wait_acquire_default_for_executing( &lock_context );
48  api = executing->API_Extensions[ THREAD_API_RTEMS ];
49  event = &api->System_event;
50 
51  if ( !_Event_sets_Is_empty( event_in ) ) {
52  sc = _Event_Seize(
53  event_in,
54  option_set,
55  ticks,
56  event_out,
57  executing,
58  event,
61  &lock_context
62  );
63  } else {
64  *event_out = event->pending_events;
65  _Thread_Wait_release_default( executing, &lock_context );
66  sc = RTEMS_SUCCESSFUL;
67  }
68  } else {
70  }
71 
72  return sc;
73 }
uint32_t rtems_option
This type is used to represent an option set.
Definition: options.h:121
#define STATES_WAITING_FOR_SYSTEM_EVENT
Definition: statesimpl.h:57
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 System_event
Definition: tasksdata.h:45
Classic Event Manager Implementation.
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code rtems_event_system_receive(rtems_event_set event_in, rtems_option option_set, rtems_interval ticks, rtems_event_set *event_out)
Receives or gets a system event set.
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
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 THREAD_WAIT_CLASS_SYSTEM_EVENT
Indicates that the thread waits for a system event.
Definition: threadimpl.h:2178
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
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.