Implement taskqueue_poll_is_busy() for use by the LinuxKPI.

Refer to comment above function for a detailed description.

Discussed with:		kib @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
hselasky 2017-03-02 12:20:23 +00:00
parent aa7ab7b7d4
commit df21508671
2 changed files with 18 additions and 0 deletions

View File

@ -487,6 +487,23 @@ task_is_running(struct taskqueue *queue, struct task *task)
return (0);
}
/*
* Only use this function in single threaded contexts. It returns
* non-zero if the given task is either pending or running. Else the
* task is idle and can be queued again or freed.
*/
int
taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task)
{
int retval;
TQ_LOCK(queue);
retval = task->ta_pending > 0 || task_is_running(queue, task);
TQ_UNLOCK(queue);
return (retval);
}
static int
taskqueue_cancel_locked(struct taskqueue *queue, struct task *task,
u_int *pendp)

View File

@ -79,6 +79,7 @@ int taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count,
int taskqueue_enqueue(struct taskqueue *queue, struct task *task);
int taskqueue_enqueue_timeout(struct taskqueue *queue,
struct timeout_task *timeout_task, int ticks);
int taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task);
int taskqueue_cancel(struct taskqueue *queue, struct task *task,
u_int *pendp);
int taskqueue_cancel_timeout(struct taskqueue *queue,