* @brief This function will wake up all pending thread on the specified * waiting queue that meets the conditions. * * @param queue is a pointer to the wait queue. * * @param key is the wakeup conditions, but it is not effective now, because * default wakeup function always return 0. * If user wants to use it, user should define their own wakeup *
| 134 | * function. |
| 135 | */ |
| 136 | void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key) |
| 137 | { |
| 138 | rt_base_t level; |
| 139 | int need_schedule = 0; |
| 140 | |
| 141 | rt_list_t *queue_list; |
| 142 | struct rt_list_node *node; |
| 143 | struct rt_wqueue_node *entry; |
| 144 | |
| 145 | queue_list = &(queue->waiting_list); |
| 146 | |
| 147 | level = rt_spin_lock_irqsave(&(queue->spinlock)); |
| 148 | /* set wakeup flag in the queue */ |
| 149 | queue->flag = RT_WQ_FLAG_WAKEUP; |
| 150 | |
| 151 | if (!(rt_list_isempty(queue_list))) |
| 152 | { |
| 153 | for (node = queue_list->next; node != queue_list; ) |
| 154 | { |
| 155 | entry = rt_list_entry(node, struct rt_wqueue_node, list); |
| 156 | if (entry->wakeup(entry, key) == 0) |
| 157 | { |
| 158 | /** |
| 159 | * even though another thread may interrupt the thread and |
| 160 | * wakeup it meanwhile, we can asuume that condition is ready |
| 161 | */ |
| 162 | entry->polling_thread->error = RT_EOK; |
| 163 | if (!rt_thread_resume(entry->polling_thread)) |
| 164 | { |
| 165 | need_schedule = 1; |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | /* wakeup happened too soon that waker hadn't slept */ |
| 170 | LOG_D("%s: Thread resume failed", __func__); |
| 171 | } |
| 172 | node = node->next; |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | node = node->next; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | rt_spin_unlock_irqrestore(&(queue->spinlock), level); |
| 181 | if (need_schedule) |
| 182 | rt_schedule(); |
| 183 | |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * @brief This function will join a thread to the specified waiting queue, the thread will holds a wait or |
no test coverage detected