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

Function rt_wqueue_wakeup_all

components/drivers/ipc/waitqueue.c:136–185  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

134 * function.
135 */
136void 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

Callers 7

lwp_pid_putFunction · 0.85
lwp_tty_deleteFunction · 0.85
ptsdrv_outwakeupFunction · 0.85
ptsdrv_inwakeupFunction · 0.85
ptsdrv_freeFunction · 0.85
tty_wakeupFunction · 0.85
rt_condvar_broadcastFunction · 0.85

Calls 5

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

Tested by

no test coverage detected