Xenomai API  2.6.5
event.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_EVENT_H
23 #define _XENO_EVENT_H
24 
25 #include <nucleus/synch.h>
26 #include <native/types.h>
27 
28 /* Creation flags. */
29 #define EV_PRIO XNSYNCH_PRIO /* Pend by task priority order. */
30 #define EV_FIFO XNSYNCH_FIFO /* Pend by FIFO order. */
31 
32 /* Operation flags. */
33 #define EV_ANY 0x1 /* Disjunctive wait. */
34 #define EV_ALL 0x0 /* Conjunctive wait. */
35 
36 typedef struct rt_event_info {
37 
38  unsigned long value; /* !< Current event group value. */
39 
40  int nwaiters; /* !< Number of pending tasks. */
41 
42  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
43 
44 } RT_EVENT_INFO;
45 
46 typedef struct rt_event_placeholder {
47  xnhandle_t opaque;
48 } RT_EVENT_PLACEHOLDER;
49 
50 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
51 
52 #include <native/ppd.h>
53 
54 #define XENO_EVENT_MAGIC 0x55550404
55 
56 typedef struct rt_event {
57 
58  unsigned magic; /* !< Magic code - must be first */
59 
60  xnsynch_t synch_base; /* !< Base synchronization object. */
61 
62  unsigned long value; /* !< Event group value. */
63 
64  xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */
65 
66  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
67 
68 #ifdef CONFIG_XENO_OPT_PERVASIVE
69  pid_t cpid; /* !< Creator's pid. */
70 #endif /* CONFIG_XENO_OPT_PERVASIVE */
71 
72  xnholder_t rlink; /* !< Link in resource queue. */
73 
74 #define rlink2event(ln) container_of(ln, RT_EVENT, rlink)
75 
76  xnqueue_t *rqueue; /* !< Backpointer to resource queue. */
77 
78 } RT_EVENT;
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 #ifdef CONFIG_XENO_OPT_NATIVE_EVENT
85 
86 int __native_event_pkg_init(void);
87 
88 void __native_event_pkg_cleanup(void);
89 
90 static inline void __native_event_flush_rq(xnqueue_t *rq)
91 {
92  xeno_flush_rq(RT_EVENT, rq, event);
93 }
94 
95 int rt_event_wait_inner(RT_EVENT *event,
96  unsigned long mask,
97  unsigned long *mask_r,
98  int mode, xntmode_t timeout_mode, RTIME timeout);
99 
100 #else /* !CONFIG_XENO_OPT_NATIVE_EVENT */
101 
102 #define __native_event_pkg_init() ({ 0; })
103 #define __native_event_pkg_cleanup() do { } while(0)
104 #define __native_event_flush_rq(rq) do { } while(0)
105 
106 #endif /* !CONFIG_XENO_OPT_NATIVE_EVENT */
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #else /* !(__KERNEL__ || __XENO_SIM__) */
113 
114 typedef RT_EVENT_PLACEHOLDER RT_EVENT;
115 
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119 
120 int rt_event_bind(RT_EVENT *event,
121  const char *name,
122  RTIME timeout);
123 
124 static inline int rt_event_unbind (RT_EVENT *event)
125 
126 {
127  event->opaque = XN_NO_HANDLE;
128  return 0;
129 }
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* __KERNEL__ || __XENO_SIM__ */
136 
137 #ifdef __cplusplus
138 extern "C" {
139 #endif
140 
141 /* Public interface. */
142 
143 int rt_event_create(RT_EVENT *event,
144  const char *name,
145  unsigned long ivalue,
146  int mode);
147 
148 int rt_event_delete(RT_EVENT *event);
149 
150 int rt_event_signal(RT_EVENT *event,
151  unsigned long mask);
152 
153 int rt_event_wait(RT_EVENT *event,
154  unsigned long mask,
155  unsigned long *mask_r,
156  int mode,
157  RTIME timeout);
158 
159 int rt_event_wait_until(RT_EVENT *event,
160  unsigned long mask,
161  unsigned long *mask_r,
162  int mode,
163  RTIME timeout);
164 
165 int rt_event_clear(RT_EVENT *event,
166  unsigned long mask,
167  unsigned long *mask_r);
168 
169 int rt_event_inquire(RT_EVENT *event,
170  RT_EVENT_INFO *info);
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* !_XENO_EVENT_H */
int rt_event_inquire(RT_EVENT *event, RT_EVENT_INFO *info)
Inquire about an event group.
Definition: event.c:89
int rt_event_wait(RT_EVENT *event, unsigned long mask, unsigned long *mask_r, int mode, RTIME timeout)
Pend on an event group.
Definition: event.c:43
static int rt_event_unbind(RT_EVENT *event)
Unbind from an event flag group.
Definition: event.h:124
int rt_event_signal(RT_EVENT *event, unsigned long mask)
Post an event group.
Definition: event.c:77
int rt_event_wait_until(RT_EVENT *event, unsigned long mask, unsigned long *mask_r, int mode, RTIME timeout)
Pend on an event group (with absolute timeout date).
Definition: event.c:60
This file is part of the Xenomai project.
int rt_event_bind(RT_EVENT *event, const char *name, RTIME timeout)
Bind to an event flag group.
Definition: event.c:32
int rt_event_create(RT_EVENT *event, const char *name, unsigned long ivalue, int mode)
Create an event group.
Definition: event.c:24
int rt_event_clear(RT_EVENT *event, unsigned long mask, unsigned long *mask_r)
Clear an event group.
Definition: event.c:83
int rt_event_delete(RT_EVENT *event)
Delete an event group.
Definition: event.c:38
This file is part of the Xenomai project.