XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
xwmq.c
浏览该文件的文档.
1
13#include <xwos/standard.h>
14#include <xwos/lib/object.h>
15#include <xwos/mm/memslice.h>
16#include <xwmd/isc/xwmq/mif.h>
17
18static __xwmd_code
19void xwmq_msg_construct(struct xwmq_msg * msg);
20
21static __xwmd_code
22void xwmq_construct(struct xwmq * mq)
23{
25}
26
27static __xwmd_code
28void xwmq_destruct(struct xwmq * mq)
29{
31}
32
33static __xwmd_code
35{
36 struct xwmq * mq;
37
38 mq = xwcc_derof(obj, struct xwmq, xwobj);
41 xwmq_destruct(mq);
42 return XWOK;
43}
44
47{
48 xwsq_t tik;
49
50 if (NULL != mq) {
51 tik = mq->xwobj.tik;
52 } else {
53 tik = 0;
54 }
55 return tik;
56}
57
60{
61 return xwos_object_acquire(&mqd.mq->xwobj, mqd.tik);
62}
63
66{
67 return xwos_object_release(&mqd.mq->xwobj, mqd.tik);
68}
69
71xwer_t xwmq_grab(struct xwmq * mq)
72{
73 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
74
75 return xwos_object_grab(&mq->xwobj);
76}
77
79xwer_t xwmq_put(struct xwmq * mq)
80{
81 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
82
83 return xwos_object_put(&mq->xwobj);
84}
85
86static __xwmd_rodata
87const char xwmq_txq_name[] = "xwmq.txq";
88
89static __xwmd_code
91 struct xwmq_msg * txq, xwsz_t num,
92 xwobj_gc_f gcfunc)
93{
94 xwer_t rc;
95
96 rc = xwos_object_activate(&mq->xwobj, gcfunc);
97 if (rc < 0) {
98 goto err_xwobj_activate;
99 }
100 rc = xwmm_memslice_init(&mq->txq,
101 (xwptr_t)txq,
102 sizeof(struct xwmq_msg) * num,
103 sizeof(struct xwmq_msg), xwmq_txq_name,
105 if (rc < 0) {
106 goto err_memslice_init;
107 }
108 xwos_sem_init(&mq->txqsem, (xwssq_t)num, (xwssq_t)num);
111 xwos_sem_init(&mq->rxqsem, 0, (xwssq_t)num);
112 return XWOK;
113
114err_memslice_init:
115 xwmq_put(mq); // cppcheck-suppress [misra-c2012-17.7]
116err_xwobj_activate:
117 return rc;
118}
119
121xwer_t xwmq_init(struct xwmq * mq, struct xwmq_msg * txq, xwsz_t num)
122{
123 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
124 XWOS_VALIDATE((txq), "nullptr", -EFAULT);
125
126 xwmq_construct(mq);
127 return xwmq_activate(mq, txq, num, xwmq_gc);
128}
129
132{
133 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
134 return xwmq_put(mq);
135}
136
141static __xwmd_code
142void xwmq_msg_construct(struct xwmq_msg * msg)
143{
145 msg->topic = 0;
146 msg->data = NULL;
147}
148
152static __xwmd_code
153struct xwmq_msg * xwmq_msg_get(struct xwmq * mq)
154{
155 union {
156 struct xwmq_msg * msg;
157 void * anon;
158 } mem;
159
160 // cppcheck-suppress [misra-c2012-17.7]
161 xwmm_memslice_alloc(&mq->txq, &mem.anon);
162 return mem.msg;
163}
164
168static __xwmd_code
169void xwmq_msg_put(struct xwmq * mq, struct xwmq_msg * msg)
170{
171 // cppcheck-suppress [misra-c2012-17.7]
172 xwmm_memslice_free(&mq->txq, msg);
173}
174
176xwer_t xwmq_eq(struct xwmq * mq, xwsq_t topic, void * data)
177{
178 return xwmq_eq_to(mq, topic, data, XWTM_MAX);
179}
180
182xwer_t xwmq_eq_to(struct xwmq * mq, xwsq_t topic, void * data, xwtm_t to)
183{
184 xwer_t rc;
185 xwreg_t cpuirq;
186 struct xwmq_msg * msg;
187
188 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
189 XWOS_VALIDATE((data), "nullptr", -EFAULT);
190
191 rc = xwos_sem_wait_to(&mq->txqsem, to);
192 if (rc < 0) {
193 goto err_sem_wait_to;
194 }
195 msg = xwmq_msg_get(mq);
196 msg->topic = topic;
197 msg->data = data;
198 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
199 xwlib_bclst_add_tail(&mq->rxq, &msg->node);
201 xwos_sem_post(&mq->rxqsem);
202 return XWOK;
203
204err_sem_wait_to:
205 return rc;
206}
207
210{
211 xwer_t rc;
212 xwreg_t cpuirq;
213 struct xwmq_msg * msg;
214
215 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
216 XWOS_VALIDATE((data), "nullptr", -EFAULT);
217
218 rc = xwos_sem_wait_unintr(&mq->txqsem);
219 if (rc < 0) {
220 goto err_sem_wait_unintr;
221 }
222 msg = xwmq_msg_get(mq);
223 msg->topic = topic;
224 msg->data = data;
225 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
226 xwlib_bclst_add_tail(&mq->rxq, &msg->node);
228 xwos_sem_post(&mq->rxqsem);
229 return XWOK;
230
231err_sem_wait_unintr:
232 return rc;
233}
234
236xwer_t xwmq_tryeq(struct xwmq * mq, xwsq_t topic, void * data)
237{
238 xwer_t rc;
239 xwreg_t cpuirq;
240 struct xwmq_msg * msg;
241
242 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
243 XWOS_VALIDATE((data), "nullptr", -EFAULT);
244
245 rc = xwos_sem_trywait(&mq->txqsem);
246 if (rc < 0) {
247 goto err_sem_trywait;
248 }
249 msg = xwmq_msg_get(mq);
250 msg->topic = topic;
251 msg->data = data;
252 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
253 xwlib_bclst_add_tail(&mq->rxq, &msg->node);
255 xwos_sem_post(&mq->rxqsem);
256 return XWOK;
257
258err_sem_trywait:
259 return rc;
260}
261
263xwer_t xwmq_jq(struct xwmq * mq, xwsq_t topic, void * data)
264{
265 return xwmq_jq_to(mq, topic, data, XWTM_MAX);
266}
267
269xwer_t xwmq_jq_to(struct xwmq * mq, xwsq_t topic, void * data, xwtm_t to)
270{
271 xwer_t rc;
272 xwreg_t cpuirq;
273 struct xwmq_msg * msg;
274
275 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
276 XWOS_VALIDATE((data), "nullptr", -EFAULT);
277
278 rc = xwos_sem_wait_to(&mq->txqsem, to);
279 if (rc < 0) {
280 goto err_sem_wait_to;
281 }
282 msg = xwmq_msg_get(mq);
283 msg->topic = topic;
284 msg->data = data;
285 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
286 xwlib_bclst_add_head(&mq->rxq, &msg->node);
288 xwos_sem_post(&mq->rxqsem);
289 return XWOK;
290
291err_sem_wait_to:
292 return rc;
293}
294
297{
298 xwer_t rc;
299 xwreg_t cpuirq;
300 struct xwmq_msg * msg;
301
302 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
303 XWOS_VALIDATE((data), "nullptr", -EFAULT);
304
305 rc = xwos_sem_wait_unintr(&mq->txqsem);
306 if (rc < 0) {
307 goto err_sem_wait_unintr;
308 }
309 msg = xwmq_msg_get(mq);
310 msg->topic = topic;
311 msg->data = data;
312 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
313 xwlib_bclst_add_head(&mq->rxq, &msg->node);
315 xwos_sem_post(&mq->rxqsem);
316 return XWOK;
317
318err_sem_wait_unintr:
319 return rc;
320}
321
323xwer_t xwmq_tryjq(struct xwmq * mq, xwsq_t topic, void * data)
324{
325 xwer_t rc;
326 xwreg_t cpuirq;
327 struct xwmq_msg * msg;
328
329 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
330 XWOS_VALIDATE((data), "nullptr", -EFAULT);
331
332 rc = xwos_sem_trywait(&mq->txqsem);
333 if (rc < 0) {
334 goto err_sem_trywait;
335 }
336 msg = xwmq_msg_get(mq);
337 msg->topic = topic;
338 msg->data = data;
339 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
340 xwlib_bclst_add_head(&mq->rxq, &msg->node);
342 xwos_sem_post(&mq->rxqsem);
343 return XWOK;
344
345err_sem_trywait:
346 return rc;
347}
348
353static __xwmd_code
354struct xwmq_msg * xwmq_choose_head(struct xwmq * mq)
355{
356 struct xwmq_msg * msg;
357 xwreg_t cpuirq;
358
359 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
360 msg = xwlib_bclst_first_entry(&mq->rxq,
361 struct xwmq_msg,
362 node);
365 return msg;
366}
367
372static __xwmd_code
373struct xwmq_msg * xwmq_choose_tail(struct xwmq * mq)
374{
375 struct xwmq_msg * msg;
376 xwreg_t cpuirq;
377
378 xwos_splk_lock_cpuirqsv(&mq->rxqlock, &cpuirq);
379 msg = xwlib_bclst_last_entry(&mq->rxq,
380 struct xwmq_msg,
381 node);
384 return msg;
385}
386
388xwer_t xwmq_dq(struct xwmq * mq, xwsq_t * topic, void ** databuf)
389{
390 return xwmq_dq_to(mq, topic, databuf, XWTM_MAX);
391}
392
394xwer_t xwmq_dq_to(struct xwmq * mq, xwsq_t * topic, void ** databuf, xwtm_t to)
395{
396 xwer_t rc;
397 struct xwmq_msg * msg;
398
399 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
400 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
401 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
402
403 rc = xwos_sem_wait_to(&mq->rxqsem, to);
404 if (rc < 0) {
405 goto err_sem_wait_to;
406 }
407 msg = xwmq_choose_head(mq);
408 *databuf = msg->data;
409 if (NULL != topic) {
410 *topic = msg->topic;
411 }
412 xwmq_msg_put(mq, msg);
413 xwos_sem_post(&mq->txqsem);
414 return XWOK;
415
416err_sem_wait_to:
417 return rc;
418}
419
421xwer_t xwmq_dq_unintr(struct xwmq * mq, xwsq_t * topic, void ** databuf)
422{
423 xwer_t rc;
424 struct xwmq_msg * msg;
425
426 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
427 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
428 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
429
430 rc = xwos_sem_wait_unintr(&mq->rxqsem);
431 if (rc < 0) {
432 goto err_sem_wait_unintr;
433 }
434 msg = xwmq_choose_head(mq);
435 *databuf = msg->data;
436 if (NULL != topic) {
437 *topic = msg->topic;
438 }
439 xwmq_msg_put(mq, msg);
440 xwos_sem_post(&mq->txqsem);
441 return XWOK;
442
443err_sem_wait_unintr:
444 return rc;
445}
446
448xwer_t xwmq_trydq(struct xwmq * mq, xwsq_t * topic, void ** databuf)
449{
450 xwer_t rc;
451 struct xwmq_msg * msg;
452
453 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
454 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
455 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
456
457 rc = xwos_sem_trywait(&mq->rxqsem);
458 if (rc < 0) {
459 goto err_sem_trywait;
460 }
461 msg = xwmq_choose_head(mq);
462 *databuf = msg->data;
463 if (NULL != topic) {
464 *topic = msg->topic;
465 }
466 xwmq_msg_put(mq, msg);
467 xwos_sem_post(&mq->txqsem);
468 return XWOK;
469
470err_sem_trywait:
471 return rc;
472}
473
475xwer_t xwmq_rq(struct xwmq * mq, xwsq_t * topic, void ** databuf)
476{
477 return xwmq_rq_to(mq, topic, databuf, XWTM_MAX);
478}
479
481xwer_t xwmq_rq_to(struct xwmq * mq, xwsq_t * topic, void ** databuf, xwtm_t to)
482{
483 xwer_t rc;
484 struct xwmq_msg * msg;
485
486 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
487 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
488 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
489
490 rc = xwos_sem_wait_to(&mq->rxqsem, to);
491 if (rc < 0) {
492 goto err_sem_wait_to;
493 }
494 msg = xwmq_choose_tail(mq);
495 *databuf = msg->data;
496 if (NULL != topic) {
497 *topic = msg->topic;
498 }
499 xwmq_msg_put(mq, msg);
500 xwos_sem_post(&mq->txqsem);
501 return XWOK;
502
503err_sem_wait_to:
504 return rc;
505}
506
508xwer_t xwmq_rq_unintr(struct xwmq * mq, xwsq_t * topic, void ** databuf)
509{
510 xwer_t rc;
511 struct xwmq_msg * msg;
512
513 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
514 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
515 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
516
517 rc = xwos_sem_wait_unintr(&mq->rxqsem);
518 if (rc < 0) {
519 goto err_sem_wait_unintr;
520 }
521 msg = xwmq_choose_tail(mq);
522 *databuf = msg->data;
523 if (NULL != topic) {
524 *topic = msg->topic;
525 }
526 xwmq_msg_put(mq, msg);
527 xwos_sem_post(&mq->txqsem);
528 return XWOK;
529
530err_sem_wait_unintr:
531 return rc;
532}
533
535xwer_t xwmq_tryrq(struct xwmq * mq, xwsq_t * topic, void ** databuf)
536{
537 xwer_t rc;
538 struct xwmq_msg * msg;
539
540 XWOS_VALIDATE((mq), "nullptr", -EFAULT);
541 XWOS_VALIDATE((topic), "nullptr", -EFAULT);
542 XWOS_VALIDATE((databuf), "nullptr", -EFAULT);
543
544 rc = xwos_sem_trywait(&mq->rxqsem);
545 if (rc < 0) {
546 goto err_sem_trywait;
547 }
548 msg = xwmq_choose_tail(mq);
549 *databuf = msg->data;
550 if (NULL != topic) {
551 *topic = msg->topic;
552 }
553 xwmq_msg_put(mq, msg);
554 xwos_sem_post(&mq->txqsem);
555 return XWOK;
556
557err_sem_trywait:
558 return rc;
559}
xwer_t xwmq_jq_to(struct xwmq *mq, xwsq_t topic, void *data, xwtm_t to)
XWMQ API:限时等待消息槽,成功后将消息发送到消息队列的 首端 (插队)
Definition xwmq.c:269
xwer_t xwmq_trydq(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 尝试从消息队列 首端 接收一条消息
Definition xwmq.c:448
xwer_t xwmq_acquire(xwmq_d mqd)
XWMQ API:检查消息队列对象的标签并增加引用计数
Definition xwmq.c:59
xwer_t xwmq_jq(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:等待消息槽,成功后将消息发送到消息队列的 首端 (插队)
Definition xwmq.c:263
xwer_t xwmq_rq_unintr(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 等待从消息队列 尾端 接收一条消息,且等待不可被中断
Definition xwmq.c:508
xwer_t xwmq_tryeq(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:尝试获取消息槽,成功后将消息发送到消息队列的 尾端 (入队)
Definition xwmq.c:236
xwer_t xwmq_put(struct xwmq *mq)
XWMQ API:减少消息队列对象的引用计数
Definition xwmq.c:79
xwer_t xwmq_jq_unintr(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:等待消息槽,且等待不可被中断, 成功后将消息发送到消息队列的 首端 (插队)
Definition xwmq.c:296
xwer_t xwmq_init(struct xwmq *mq, struct xwmq_msg *txq, xwsz_t num)
XWMQ API:静态方式初始化消息队列
Definition xwmq.c:121
xwer_t xwmq_release(xwmq_d mqd)
XWMQ API:检查消息队列对象的标签并减少引用计数
Definition xwmq.c:65
xwer_t xwmq_fini(struct xwmq *mq)
XWMQ API:销毁静态方式初始化的消息队列对象
Definition xwmq.c:131
xwsq_t xwmq_get_tik(struct xwmq *mq)
XWMQ API:获取消息队列对象的标签
Definition xwmq.c:46
xwer_t xwmq_dq(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 等待从消息队列 首端 接收一条消息
Definition xwmq.c:388
xwer_t xwmq_tryjq(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:尝试获取消息槽,成功后将消息发送到消息队列的 首端 (插队)
Definition xwmq.c:323
xwer_t xwmq_rq(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 等待从消息队列 尾端 接收一条消息
Definition xwmq.c:475
xwer_t xwmq_tryrq(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 尝试从消息队列 尾端 接收一条消息
Definition xwmq.c:535
xwer_t xwmq_eq_to(struct xwmq *mq, xwsq_t topic, void *data, xwtm_t to)
XWMQ API:限时等待消息槽,成功后将消息发送到消息队列的 尾端 (入队)
Definition xwmq.c:182
xwer_t xwmq_eq_unintr(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:等待消息槽,且等待不可被中断, 成功后将消息发送到消息队列的 尾端 (入队)
Definition xwmq.c:209
xwer_t xwmq_grab(struct xwmq *mq)
XWMQ API:增加消息队列对象的引用计数
Definition xwmq.c:71
xwer_t xwmq_dq_unintr(struct xwmq *mq, xwsq_t *topic, void **databuf)
XWMQ API: 等待从消息队列 首端 接收一条消息,且等待不可被中断
Definition xwmq.c:421
xwer_t xwmq_dq_to(struct xwmq *mq, xwsq_t *topic, void **databuf, xwtm_t to)
XWMQ API: 限时等待从消息队列 首端 接收一条消息
Definition xwmq.c:394
xwer_t xwmq_rq_to(struct xwmq *mq, xwsq_t *topic, void **databuf, xwtm_t to)
XWMQ API: 限时等待从消息队列 尾端 接收一条消息
Definition xwmq.c:481
xwer_t xwmq_eq(struct xwmq *mq, xwsq_t topic, void *data)
XWMQ API:等待消息槽,成功后将消息发送到消息队列的 尾端 (入队)
Definition xwmq.c:176
xwer_t xwmm_memslice_free(struct xwmm_memslice *msa, void *mem)
XWMM API:释放内存切片
Definition memslice.c:107
xwer_t xwmm_memslice_init(struct xwmm_memslice *msa, xwptr_t origin, xwsz_t total_size, xwsz_t card_size, const char *name, ctor_f ctor, dtor_f dtor)
XWMM API:静态方式初始化内存切片分配器
Definition memslice.c:21
xwer_t xwmm_memslice_alloc(struct xwmm_memslice *msa, void **membuf)
XWMM API:申请内存切片
Definition memslice.c:83
static void xwlib_bclst_init_head(struct xwlib_bclst_node *h)
初始化一个链表头。
Definition bclst.h:229
static void xwlib_bclst_add_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表尾部(链表头的前面)
Definition bclst.h:357
static void xwlib_bclst_init_node(struct xwlib_bclst_node *n)
初始化一个链表节点。
Definition bclst.h:240
static void xwlib_bclst_add_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表头部(链表头的后面)
Definition bclst.h:345
static void xwlib_bclst_del_init(struct xwlib_bclst_node *node)
删除一个节点,并重新初始化它
Definition bclst.h:391
#define xwlib_bclst_last_entry(head, type, member)
获得包含链表最后一个节点的外层结构体的指针。
Definition bclst.h:73
#define xwlib_bclst_first_entry(head, type, member)
获得包含链表第一个节点的外层结构体的指针。
Definition bclst.h:63
#define __xwmd_api
Definition compiler.h:363
#define xwcc_derof(baseptr, derclass, member)
将基类结构体指针转换为派生类结构体指针
Definition compiler.h:501
#define __xwmd_rodata
Definition compiler.h:383
#define __xwmd_code
Definition compiler.h:359
#define EFAULT
Bad address
Definition errno.h:44
#define XWOK
No error
Definition errno.h:182
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
#define XWTM_MAX
xwtm_t 的最大值
Definition type.h:755
signed long xwer_t
Definition type.h:554
#define NULL
Definition type.h:28
unsigned long xwsz_t
Definition type.h:339
unsigned long xwsq_t
Definition type.h:445
signed long xwssq_t
Definition type.h:461
unsigned long xwptr_t
Definition type.h:375
xwptr_t xwreg_t
Definition type.h:409
void(* ctor_f)(void *)
Definition type.h:604
xwer_t(* xwobj_gc_f)(struct xwos_object *)
垃圾回收函数指针类型
Definition object.h:42
xwer_t xwos_object_grab(struct xwos_object *obj)
增加对象的引用计数
Definition object.c:297
xwer_t xwos_object_activate(struct xwos_object *obj, xwobj_gc_f gcfunc)
激活一个XWOS对象(将其引用计数初始化位1)
Definition object.c:135
void xwos_object_construct(struct xwos_object *obj)
XWOS对象的构造函数
Definition object.c:107
void xwos_object_destruct(struct xwos_object *obj)
XWOS对象的析构函数
Definition object.c:119
xwer_t xwos_object_release(struct xwos_object *obj, xwsq_t tik)
检查对象的标签并减少引用计数
Definition object.c:265
xwer_t xwos_object_acquire(struct xwos_object *obj, xwsq_t tik)
检查对象的标签并增加引用计数
Definition object.c:206
xwer_t xwos_object_put(struct xwos_object *obj)
减少对象的引用计数
Definition object.c:316
static void xwos_splk_unlock_cpuirqrs(struct xwos_splk *spl, xwreg_t cpuirq)
XWOS API:解锁自旋锁,并恢复本地CPU的中断标志
Definition spinlock.h:224
static void xwos_splk_init(struct xwos_splk *spl)
XWOS API:初始化自旋锁
Definition spinlock.h:89
static void xwos_splk_lock_cpuirqsv(struct xwos_splk *spl, xwreg_t *cpuirq)
XWOS API:上锁自旋锁,保存本地CPU的中断标志并关闭
Definition spinlock.h:192
#define XWOS_VALIDATE(exp, errstr,...)
检查函数参数是否有效
Definition standard.h:76
static xwer_t xwos_sem_trywait(struct xwos_sem *sem)
XWOS API:尝试获取信号量
Definition sem.h:454
static xwer_t xwos_sem_wait_unintr(struct xwos_sem *sem)
XWOS API:等待并获取信号量,且等待不可被中断
Definition sem.h:436
static xwer_t xwos_sem_fini(struct xwos_sem *sem)
XWOS API:销毁静态方式初始化的信号量对象
Definition sem.h:140
static xwer_t xwos_sem_wait_to(struct xwos_sem *sem, xwtm_t to)
XWOS API:限时等待并获取信号量
Definition sem.h:418
static xwer_t xwos_sem_init(struct xwos_sem *sem, xwssq_t val, xwssq_t max)
XWOS API:静态方式初始化信号量对象
Definition sem.h:125
static xwer_t xwos_sem_post(struct xwos_sem *sem)
XWOS API:发布信号量
Definition sem.h:373
XWOS内存管理:内存切片分配器
消息队列对象描述符
Definition mif.h:110
xwsq_t tik
Definition mif.h:112
struct xwmq * mq
Definition mif.h:111
消息队列的消息
Definition mif.h:87
struct xwlib_bclst_node node
Definition mif.h:90
void * data
Definition mif.h:88
xwsq_t topic
Definition mif.h:89
消息队列对象
Definition mif.h:97
struct xwos_sem rxqsem
Definition mif.h:104
struct xwos_object xwobj
Definition mif.h:98
struct xwmm_memslice txq
Definition mif.h:100
struct xwos_sem txqsem
Definition mif.h:101
struct xwlib_bclst_node rxq
Definition mif.h:102
struct xwos_splk rxqlock
Definition mif.h:103
XWOS对象
Definition object.h:53
xwsq_t tik
Definition object.h:54
消息队列:模块接口
static struct xwmq_msg * xwmq_msg_get(struct xwmq *mq)
获取一个消息槽
Definition xwmq.c:153
static void xwmq_destruct(struct xwmq *mq)
Definition xwmq.c:28
static void xwmq_msg_put(struct xwmq *mq, struct xwmq_msg *msg)
释放一个消息槽
Definition xwmq.c:169
static const char xwmq_txq_name[]
Definition xwmq.c:87
static xwer_t xwmq_gc(struct xwos_object *obj)
Definition xwmq.c:34
static xwer_t xwmq_activate(struct xwmq *mq, struct xwmq_msg *txq, xwsz_t num, xwobj_gc_f gcfunc)
Definition xwmq.c:90
static struct xwmq_msg * xwmq_choose_tail(struct xwmq *mq)
从消息接收队列尾部选择一条消息
Definition xwmq.c:373
static void xwmq_construct(struct xwmq *mq)
Definition xwmq.c:22
static void xwmq_msg_construct(struct xwmq_msg *msg)
消息槽的构造函数
Definition xwmq.c:142
static struct xwmq_msg * xwmq_choose_head(struct xwmq *mq)
从消息接收队列头部选择一条消息
Definition xwmq.c:354
XWOS通用库:XWOS的对象
XWOS的标准头文件