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. */
| 100 | * up. It's safe to call this function in interrupt context. |
| 101 | */ |
| 102 | rt_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 | } |
no test coverage detected