Lines Matching refs:task
60 struct task *tb_running;
66 STAILQ_HEAD(, task) tq_queue;
68 struct task *tq_hint;
224 taskqueue_enqueue_locked(struct taskqueue *queue, struct task *task) in taskqueue_enqueue_locked() argument
226 struct task *ins; in taskqueue_enqueue_locked()
227 struct task *prev; in taskqueue_enqueue_locked()
229 KASSERT(task->ta_func != NULL, ("enqueueing task with NULL func")); in taskqueue_enqueue_locked()
233 if (task->ta_pending) { in taskqueue_enqueue_locked()
234 if (task->ta_pending < USHRT_MAX) in taskqueue_enqueue_locked()
235 task->ta_pending++; in taskqueue_enqueue_locked()
246 prev = STAILQ_LAST(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
247 if (!prev || prev->ta_priority >= task->ta_priority) { in taskqueue_enqueue_locked()
248 STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
251 if (prev && prev->ta_priority >= task->ta_priority) { in taskqueue_enqueue_locked()
258 if (ins->ta_priority < task->ta_priority) in taskqueue_enqueue_locked()
262 STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link); in taskqueue_enqueue_locked()
263 queue->tq_hint = task; in taskqueue_enqueue_locked()
265 STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
268 task->ta_pending = 1; in taskqueue_enqueue_locked()
281 taskqueue_enqueue(struct taskqueue *queue, struct task *task) in taskqueue_enqueue() argument
286 res = taskqueue_enqueue_locked(queue, task); in taskqueue_enqueue()
366 struct task t_barrier; in taskqueue_drain_tq_queue()
452 struct task *task; in taskqueue_run_locked() local
462 while ((task = STAILQ_FIRST(&queue->tq_queue)) != NULL) { in taskqueue_run_locked()
464 if (queue->tq_hint == task) in taskqueue_run_locked()
466 pending = task->ta_pending; in taskqueue_run_locked()
467 task->ta_pending = 0; in taskqueue_run_locked()
468 tb.tb_running = task; in taskqueue_run_locked()
472 KASSERT(task->ta_func != NULL, ("task->ta_func is NULL")); in taskqueue_run_locked()
473 if (!in_net_epoch && TASK_IS_NET(task)) { in taskqueue_run_locked()
476 } else if (in_net_epoch && !TASK_IS_NET(task)) { in taskqueue_run_locked()
480 task->ta_func(task->ta_context, pending); in taskqueue_run_locked()
483 wakeup(task); in taskqueue_run_locked()
500 task_is_running(struct taskqueue *queue, struct task *task) in task_is_running() argument
506 if (tb->tb_running == task) in task_is_running()
518 taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task) in taskqueue_poll_is_busy() argument
523 retval = task->ta_pending > 0 || task_is_running(queue, task); in taskqueue_poll_is_busy()
530 taskqueue_cancel_locked(struct taskqueue *queue, struct task *task, in taskqueue_cancel_locked() argument
534 if (task->ta_pending > 0) { in taskqueue_cancel_locked()
535 STAILQ_REMOVE(&queue->tq_queue, task, task, ta_link); in taskqueue_cancel_locked()
536 if (queue->tq_hint == task) in taskqueue_cancel_locked()
540 *pendp = task->ta_pending; in taskqueue_cancel_locked()
541 task->ta_pending = 0; in taskqueue_cancel_locked()
542 return (task_is_running(queue, task) ? EBUSY : 0); in taskqueue_cancel_locked()
546 taskqueue_cancel(struct taskqueue *queue, struct task *task, u_int *pendp) in taskqueue_cancel() argument
551 error = taskqueue_cancel_locked(queue, task, pendp); in taskqueue_cancel()
579 taskqueue_drain(struct taskqueue *queue, struct task *task) in taskqueue_drain() argument
586 while (task->ta_pending != 0 || task_is_running(queue, task)) in taskqueue_drain()
587 TQ_SLEEP(queue, task, "tq_drain"); in taskqueue_drain()