Xenomai API  2.6.5
cond.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_COND_H
23 #define _XENO_COND_H
24 
25 #include <native/mutex.h>
26 
27 typedef struct rt_cond_info {
28 
29  int nwaiters; /* !< Number of pending tasks. */
30 
31  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
32 
33 } RT_COND_INFO;
34 
35 typedef struct rt_cond_placeholder {
36 
37  xnhandle_t opaque;
38 
39 } RT_COND_PLACEHOLDER;
40 
41 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
42 
43 #include <nucleus/synch.h>
44 #include <native/ppd.h>
45 
46 #define XENO_COND_MAGIC 0x55550606
47 
48 typedef struct rt_cond {
49 
50  unsigned magic; /* !< Magic code - must be first */
51 
52  xnsynch_t synch_base; /* !< Base synchronization object. */
53 
54  xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */
55 
56  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
57 
58 #ifdef CONFIG_XENO_OPT_PERVASIVE
59  pid_t cpid; /* !< Creator's pid. */
60 #endif /* CONFIG_XENO_OPT_PERVASIVE */
61 
62  xnholder_t rlink; /* !< Link in resource queue. */
63 
64 #define rlink2cond(ln) container_of(ln, RT_COND, rlink)
65 
66  xnqueue_t *rqueue; /* !< Backpointer to resource queue. */
67 
68 } RT_COND;
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 #ifdef CONFIG_XENO_OPT_NATIVE_COND
75 
76 int __native_cond_pkg_init(void);
77 
78 void __native_cond_pkg_cleanup(void);
79 
80 static inline void __native_cond_flush_rq(xnqueue_t *rq)
81 {
82  xeno_flush_rq(RT_COND, rq, cond);
83 }
84 
85 int rt_cond_wait_prologue(RT_COND *cond, RT_MUTEX *mutex, unsigned *plockcnt,
86  xntmode_t timeout_mode, RTIME timeout);
87 
88 int rt_cond_wait_epilogue(RT_MUTEX *mutex, unsigned lockcnt);
89 
90 #else /* !CONFIG_XENO_OPT_NATIVE_COND */
91 
92 #define __native_cond_pkg_init() ({ 0; })
93 #define __native_cond_pkg_cleanup() do { } while(0)
94 #define __native_cond_flush_rq(rq) do { } while(0)
95 
96 #endif /* !CONFIG_XENO_OPT_NATIVE_COND */
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #else /* !(__KERNEL__ || __XENO_SIM__) */
103 
104 typedef RT_COND_PLACEHOLDER RT_COND;
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109 
110 int rt_cond_bind(RT_COND *cond,
111  const char *name,
112  RTIME timeout);
113 
114 static inline int rt_cond_unbind (RT_COND *cond)
115 
116 {
117  cond->opaque = XN_NO_HANDLE;
118  return 0;
119 }
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* __KERNEL__ || __XENO_SIM__ */
126 
127 #ifdef __cplusplus
128 extern "C" {
129 #endif
130 
131 /* Public interface. */
132 
133 int rt_cond_create(RT_COND *cond,
134  const char *name);
135 
136 int rt_cond_delete(RT_COND *cond);
137 
138 int rt_cond_signal(RT_COND *cond);
139 
140 int rt_cond_broadcast(RT_COND *cond);
141 
142 int rt_cond_wait(RT_COND *cond,
143  RT_MUTEX *mutex,
144  RTIME timeout);
145 
146 int rt_cond_wait_until(RT_COND *cond,
147  RT_MUTEX *mutex,
148  RTIME timeout);
149 
150 int rt_cond_inquire(RT_COND *cond,
151  RT_COND_INFO *info);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif /* !_XENO_COND_H */
int rt_cond_delete(RT_COND *cond)
Delete a condition variable.
Definition: cond.c:39
int rt_cond_signal(RT_COND *cond)
Signal a condition variable.
Definition: cond.c:140
This file is part of the Xenomai project.
This file is part of the Xenomai project.
int rt_cond_broadcast(RT_COND *cond)
Broadcast a condition variable.
Definition: cond.c:145
int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
Wait on a condition (with absolute timeout date).
Definition: cond.c:103
int rt_cond_bind(RT_COND *cond, const char *name, RTIME timeout)
Bind to a condition variable.
Definition: cond.c:33
int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
Wait on a condition.
Definition: cond.c:66
int rt_cond_create(RT_COND *cond, const char *name)
Create a condition variable.
Definition: cond.c:27
int rt_cond_inquire(RT_COND *cond, RT_COND_INFO *info)
Inquire about a condition variable.
Definition: cond.c:150
static int rt_cond_unbind(RT_COND *cond)
Unbind from a condition variable.
Definition: cond.h:114