MCPcopy Create free account
hub / github.com/apache/nuttx / work_queue_wq

Function work_queue_wq

sched/wqueue/kwork_queue.c:157–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155 ****************************************************************************/
156
157int work_queue_wq(FAR struct kwork_wqueue_s *wqueue,
158 FAR struct work_s *work, worker_t worker,
159 FAR void *arg, clock_t delay)
160{
161 irqstate_t flags;
162 clock_t expected;
163 bool retimer;
164
165 if (wqueue == NULL || work == NULL || worker == NULL ||
166 delay > WDOG_MAX_DELAY)
167 {
168 return -EINVAL;
169 }
170
171 expected = clock_delay2abstick(delay);
172
173 /* Interrupts are disabled so that this logic can be called from with
174 * task logic or from interrupt handling logic.
175 */
176
177 flags = spin_lock_irqsave(&wqueue->lock);
178
179 /* Ensure the work has been removed. */
180
181 retimer = work_available(work) ? false : work_remove(wqueue, work);
182
183 /* Initialize the work structure. */
184
185 work->worker = worker; /* Work callback. non-NULL means queued */
186 work->arg = arg; /* Callback argument */
187 work->qtime = expected; /* Expected time */
188
189 if (delay)
190 {
191 /* Insert to the pending list of the wqueue. */
192
193 if (work_insert_pending(wqueue, work))
194 {
195 /* Start the timer if the work is the earliest expired work. */
196
197 retimer = false;
198 wd_start_abstick(&wqueue->timer, work->qtime,
199 work_timer_expired, (wdparm_t)wqueue);
200 }
201 }
202 else
203 {
204 /* Insert to the expired list of the wqueue. */
205
206 list_add_tail(&wqueue->expired, &work->node);
207 }
208
209 if (retimer)
210 {
211 work_timer_reset(wqueue);
212 }
213
214 spin_unlock_irqrestore(&wqueue->lock, flags);

Callers 11

sim_rptun_initFunction · 0.85
sim_usbhost_initializeFunction · 0.85
usbdev_registerFunction · 0.85
sim_netdriver_initFunction · 0.85
sim_rpmsg_virtio_initFunction · 0.85
up_initializeFunction · 0.85
usrsock_registerFunction · 0.85
sim_audio_initializeFunction · 0.85
irq_default_handlerFunction · 0.85
work_queueFunction · 0.85
rpmsgdev_poll_cbFunction · 0.85

Calls 7

work_removeFunction · 0.85
work_insert_pendingFunction · 0.85
wd_start_abstickFunction · 0.85
list_add_tailFunction · 0.85
work_timer_resetFunction · 0.85
spin_unlock_irqrestoreFunction · 0.85
nxsem_postFunction · 0.85

Tested by

no test coverage detected