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

Function rt_data_queue_reset

components/drivers/ipc/dataqueue.c:365–395  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

363 * @param queue is a pointer to the data queue object.
364 */
365void 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}
396RTM_EXPORT(rt_data_queue_reset);
397
398/**

Callers 1

rt_data_queue_deinitFunction · 0.85

Calls 6

rt_spin_lock_irqsaveFunction · 0.50
rt_enter_criticalFunction · 0.50
rt_exit_criticalFunction · 0.50
rt_scheduleFunction · 0.50

Tested by

no test coverage detected