* @brief This function will reset the data queue. * * @note Calling this function will wake up all threads on the data queue * that are hanging and waiting. * * @param queue is a pointer to the data queue object. */
| 363 | * @param queue is a pointer to the data queue object. |
| 364 | */ |
| 365 | void rt_data_queue_reset(struct rt_data_queue *queue) |
| 366 | { |
| 367 | rt_base_t level; |
| 368 | |
| 369 | RT_ASSERT(queue != RT_NULL); |
| 370 | RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); |
| 371 | |
| 372 | level = rt_spin_lock_irqsave(&(queue->spinlock)); |
| 373 | |
| 374 | queue->get_index = 0; |
| 375 | queue->put_index = 0; |
| 376 | queue->is_empty = 1; |
| 377 | queue->is_full = 0; |
| 378 | |
| 379 | rt_spin_unlock_irqrestore(&(queue->spinlock), level); |
| 380 | |
| 381 | rt_enter_critical(); |
| 382 | /* wakeup all suspend threads */ |
| 383 | |
| 384 | /* resume on pop list */ |
| 385 | rt_susp_list_resume_all_irq(&queue->suspended_pop_list, RT_ERROR, |
| 386 | &(queue->spinlock)); |
| 387 | |
| 388 | /* resume on push list */ |
| 389 | rt_susp_list_resume_all_irq(&queue->suspended_push_list, RT_ERROR, |
| 390 | &(queue->spinlock)); |
| 391 | |
| 392 | rt_exit_critical(); |
| 393 | |
| 394 | rt_schedule(); |
| 395 | } |
| 396 | RTM_EXPORT(rt_data_queue_reset); |
| 397 | |
| 398 | /** |
no test coverage detected