summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Long <scottl@FreeBSD.org>2008-08-03 14:28:26 +0000
committerScott Long <scottl@FreeBSD.org>2008-08-03 14:28:26 +0000
commit99544c155a62d2290d0e4e9a62af6b574044cdb7 (patch)
tree748265038288c6914baa1061f174476db2009a52
parenta42c3f860b2e4d9ebd6fef99d5b4a5d8556dd8d2 (diff)
Notes
-rw-r--r--sys/kern/subr_taskqueue.c29
-rw-r--r--sys/sys/taskqueue.h2
2 files changed, 30 insertions, 1 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index 3e210ccbf23f..8c1c400846db 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -63,6 +63,8 @@ struct taskqueue {
};
#define TQ_FLAGS_ACTIVE (1 << 0)
+#define TQ_FLAGS_BLOCKED (1 << 1)
+#define TQ_FLAGS_PENDING (1 << 2)
static __inline void
TQ_LOCK(struct taskqueue *tq)
@@ -224,7 +226,10 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
}
task->ta_pending = 1;
- queue->tq_enqueue(queue->tq_context);
+ if ((queue->tq_flags & TQ_FLAGS_BLOCKED) == 0)
+ queue->tq_enqueue(queue->tq_context);
+ else
+ queue->tq_flags |= TQ_FLAGS_PENDING;
TQ_UNLOCK(queue);
@@ -232,6 +237,28 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
}
void
+taskqueue_block(struct taskqueue *queue)
+{
+
+ TQ_LOCK(queue);
+ queue->tq_flags |= TQ_FLAGS_BLOCKED;
+ TQ_UNLOCK(queue);
+}
+
+void
+taskqueue_unblock(struct taskqueue *queue)
+{
+
+ TQ_LOCK(queue);
+ queue->tq_flags &= ~TQ_FLAGS_BLOCKED;
+ if (queue->tq_flags & TQ_FLAGS_PENDING) {
+ queue->tq_flags &= ~TQ_FLAGS_PENDING;
+ queue->tq_enqueue(queue->tq_context);
+ }
+ TQ_UNLOCK(queue);
+}
+
+void
taskqueue_run(struct taskqueue *queue)
{
struct task *task;
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h
index c980fc187565..4065a58b3ed1 100644
--- a/sys/sys/taskqueue.h
+++ b/sys/sys/taskqueue.h
@@ -58,6 +58,8 @@ void taskqueue_drain(struct taskqueue *queue, struct task *task);
struct taskqueue *taskqueue_find(const char *name);
void taskqueue_free(struct taskqueue *queue);
void taskqueue_run(struct taskqueue *queue);
+void taskqueue_block(struct taskqueue *queue);
+void taskqueue_unblock(struct taskqueue *queue);
/*
* Functions for dedicated thread taskqueues