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

Function rt_wqueue_wakeup

components/drivers/ipc/waitqueue.c:80–123  ·  view source on GitHub ↗

* @brief This function will wake up a 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 function. */

Source from the content-addressed store, hash-verified

78 * If user wants to use it, user should define their own wakeup function.
79 */
80void rt_wqueue_wakeup(rt_wqueue_t *queue, void *key)
81{
82 rt_base_t level;
83 int need_schedule = 0;
84
85 rt_list_t *queue_list;
86 struct rt_list_node *node;
87 struct rt_wqueue_node *entry;
88
89 queue_list = &(queue->waiting_list);
90
91 level = rt_spin_lock_irqsave(&(queue->spinlock));
92 /* set wakeup flag in the queue */
93 queue->flag = RT_WQ_FLAG_WAKEUP;
94
95 if (!(rt_list_isempty(queue_list)))
96 {
97 for (node = queue_list->next; node != queue_list; node = node->next)
98 {
99 entry = rt_list_entry(node, struct rt_wqueue_node, list);
100 if (entry->wakeup(entry, key) == 0)
101 {
102 /**
103 * even though another thread may interrupt the thread and
104 * wakeup it meanwhile, we can asuume that condition is ready
105 */
106 entry->polling_thread->error = RT_EOK;
107 if (!rt_thread_resume(entry->polling_thread))
108 {
109 need_schedule = 1;
110
111 rt_list_remove(&(entry->list));
112
113 break;
114 }
115 }
116 }
117 }
118 rt_spin_unlock_irqrestore(&(queue->spinlock), level);
119 if (need_schedule)
120 rt_schedule();
121
122 return;
123}
124
125/**
126 * @brief This function will wake up all pending thread on the specified

Callers 15

lwp_waitpid_kickFunction · 0.85
serial_fops_rx_indFunction · 0.85
serial_fops_rx_indFunction · 0.85
sdhci_data_irqFunction · 0.85
usbh_serial_fops_rx_indFunction · 0.85
pipe_fops_closeFunction · 0.85
pipe_fops_readFunction · 0.85
pipe_fops_writeFunction · 0.85
rt_condvar_signalFunction · 0.85
eventfd_readFunction · 0.85
eventfd_writeFunction · 0.85

Calls 6

rt_list_isemptyFunction · 0.85
rt_thread_resumeFunction · 0.85
rt_list_removeFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.50
rt_scheduleFunction · 0.50

Tested by

no test coverage detected