aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-03-02 12:20:23 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-03-02 12:20:23 +0000
commit403f4a31ab78ce550ce7874dec8417e43522c8cd (patch)
treea51e0c6f490028f1dc0ae780dcc21a62531b25e6 /sys
parent6d1ccf40cc543fd487b9d3de0ad6efc2a05cb387 (diff)
downloadsrc-403f4a31ab78ce550ce7874dec8417e43522c8cd.tar.gz
src-403f4a31ab78ce550ce7874dec8417e43522c8cd.zip
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
Notes
Notes: svn path=/head/; revision=314553
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_taskqueue.c17
-rw-r--r--sys/sys/taskqueue.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index 34564155c682..5d43ac6ca94c 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -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)
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h
index 3cb5427cef56..583f796e2ac1 100644
--- a/sys/sys/taskqueue.h
+++ b/sys/sys/taskqueue.h
@@ -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,