MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_wm_que_dec

Function rt_wm_que_dec

components/vbus/watermark_queue.h:102–129  ·  view source on GitHub ↗

Decrease the water level. * * It should be called by the consumer that drain the water out. If the water * level reached low mark, all the thread suspended in this queue will be waken * up. It's safe to call this function in interrupt context. */

Source from the content-addressed store, hash-verified

100 * up. It's safe to call this function in interrupt context.
101 */
102rt_inline void rt_wm_que_dec(struct rt_watermark_queue *wg)
103{
104 int need_sched = 0;
105 rt_base_t level;
106
107 if (wg->level == 0)
108 return;
109
110 level = rt_hw_interrupt_disable();
111 wg->level--;
112 if (wg->level == wg->low_mark)
113 {
114 /* There should be spaces between the low mark and high mark, so it's
115 * safe to resume all the threads. */
116 while (!rt_list_isempty(&wg->suspended_threads))
117 {
118 rt_thread_t thread;
119
120 thread = RT_THREAD_LIST_NODE_ENTRY(wg->suspended_threads.next);
121 rt_thread_resume(thread);
122 need_sched = 1;
123 }
124 }
125 rt_hw_interrupt_enable(level);
126
127 if (need_sched)
128 rt_schedule();
129}

Callers 1

_bus_out_entryFunction · 0.85

Calls 5

rt_list_isemptyFunction · 0.85
rt_thread_resumeFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50
rt_scheduleFunction · 0.50

Tested by

no test coverage detected