Lines Matching refs:task

60 	struct task		*tb_running;
66 STAILQ_HEAD(, task) tq_queue;
68 struct task *tq_hint;
220 taskqueue_enqueue_locked(struct taskqueue *queue, struct task *task) in taskqueue_enqueue_locked() argument
222 struct task *ins; in taskqueue_enqueue_locked()
223 struct task *prev; in taskqueue_enqueue_locked()
225 KASSERT(task->ta_func != NULL, ("enqueueing task with NULL func")); in taskqueue_enqueue_locked()
229 if (task->ta_pending) { in taskqueue_enqueue_locked()
230 if (task->ta_pending < USHRT_MAX) in taskqueue_enqueue_locked()
231 task->ta_pending++; in taskqueue_enqueue_locked()
242 prev = STAILQ_LAST(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
243 if (!prev || prev->ta_priority >= task->ta_priority) { in taskqueue_enqueue_locked()
244 STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
247 if (prev && prev->ta_priority >= task->ta_priority) { in taskqueue_enqueue_locked()
254 if (ins->ta_priority < task->ta_priority) in taskqueue_enqueue_locked()
258 STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link); in taskqueue_enqueue_locked()
259 queue->tq_hint = task; in taskqueue_enqueue_locked()
261 STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link); in taskqueue_enqueue_locked()
264 task->ta_pending = 1; in taskqueue_enqueue_locked()
277 taskqueue_enqueue(struct taskqueue *queue, struct task *task) in taskqueue_enqueue() argument
282 res = taskqueue_enqueue_locked(queue, task); in taskqueue_enqueue()
363 struct task t_barrier; in taskqueue_drain_tq_queue()
449 struct task *task; in taskqueue_run_locked() local
459 while ((task = STAILQ_FIRST(&queue->tq_queue)) != NULL) { in taskqueue_run_locked()
461 if (queue->tq_hint == task) in taskqueue_run_locked()
463 pending = task->ta_pending; in taskqueue_run_locked()
464 task->ta_pending = 0; in taskqueue_run_locked()
465 tb.tb_running = task; in taskqueue_run_locked()
469 KASSERT(task->ta_func != NULL, ("task->ta_func is NULL")); in taskqueue_run_locked()
470 if (!in_net_epoch && TASK_IS_NET(task)) { in taskqueue_run_locked()
473 } else if (in_net_epoch && !TASK_IS_NET(task)) { in taskqueue_run_locked()
477 task->ta_func(task->ta_context, pending); in taskqueue_run_locked()
480 wakeup(task); in taskqueue_run_locked()
497 task_is_running(struct taskqueue *queue, struct task *task) in task_is_running() argument
503 if (tb->tb_running == task) in task_is_running()
515 taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task) in taskqueue_poll_is_busy() argument
520 retval = task->ta_pending > 0 || task_is_running(queue, task); in taskqueue_poll_is_busy()
527 taskqueue_cancel_locked(struct taskqueue *queue, struct task *task, in taskqueue_cancel_locked() argument
531 if (task->ta_pending > 0) { in taskqueue_cancel_locked()
532 STAILQ_REMOVE(&queue->tq_queue, task, task, ta_link); in taskqueue_cancel_locked()
533 if (queue->tq_hint == task) in taskqueue_cancel_locked()
537 *pendp = task->ta_pending; in taskqueue_cancel_locked()
538 task->ta_pending = 0; in taskqueue_cancel_locked()
539 return (task_is_running(queue, task) ? EBUSY : 0); in taskqueue_cancel_locked()
543 taskqueue_cancel(struct taskqueue *queue, struct task *task, u_int *pendp) in taskqueue_cancel() argument
548 error = taskqueue_cancel_locked(queue, task, pendp); in taskqueue_cancel()
576 taskqueue_drain(struct taskqueue *queue, struct task *task) in taskqueue_drain() argument
583 while (task->ta_pending != 0 || task_is_running(queue, task)) in taskqueue_drain()
584 TQ_SLEEP(queue, task, "tq_drain"); in taskqueue_drain()