Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
wait_q.h
Go to the documentation of this file.
1/* wait queue for multiple threads on kernel objects */
2
3/*
4 * Copyright (c) 2015 Wind River Systems, Inc.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_
10#define ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_
11
12#include <kernel_structs.h>
13#include <sys/dlist.h>
14#include <sys/rb.h>
15#include <kernel/sched_priq.h>
16#include <timeout_q.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#ifdef CONFIG_WAITQ_SCALABLE
23
24#define _WAIT_Q_FOR_EACH(wq, thread_ptr) \
25 RB_FOR_EACH_CONTAINER(&(wq)->waitq.tree, thread_ptr, base.qnode_rb)
26
27static inline void z_waitq_init(_wait_q_t *w)
28{
29 w->waitq = (struct _priq_rb) {
30 .tree = {
31 .lessthan_fn = z_priq_rb_lessthan
32 }
33 };
34}
35
36static inline struct k_thread *z_waitq_head(_wait_q_t *w)
37{
38 return (struct k_thread *)rb_get_min(&w->waitq.tree);
39}
40
41#else /* !CONFIG_WAITQ_SCALABLE: */
42
43#define _WAIT_Q_FOR_EACH(wq, thread_ptr) \
44 SYS_DLIST_FOR_EACH_CONTAINER(&((wq)->waitq), thread_ptr, \
45 base.qnode_dlist)
46
47static inline void z_waitq_init(_wait_q_t *w)
48{
49 sys_dlist_init(&w->waitq);
50}
51
52static inline struct k_thread *z_waitq_head(_wait_q_t *w)
53{
54 return (struct k_thread *)sys_dlist_peek_head(&w->waitq);
55}
56
57#endif /* !CONFIG_WAITQ_SCALABLE */
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif /* ZEPHYR_KERNEL_INCLUDE_WAIT_Q_H_ */
Doubly-linked list implementation.
static sys_dnode_t * sys_dlist_peek_head(sys_dlist_t *list)
get a reference to the head item in the list
Definition: dlist.h:298
static void sys_dlist_init(sys_dlist_t *list)
initialize list to its empty state
Definition: dlist.h:199
static struct rbnode * rb_get_min(struct rbtree *tree)
Returns the lowest-sorted member of the tree.
Definition: rb.h:115
Red/Black balanced tree data structure.
Definition: thread.h:201
timeout queue for threads on kernel objects