Revert taskqueue(9) related commits until mdf@ is approved and can

resolve issues.

This reverts commits r207439, r208623, r208624
This commit is contained in:
zml 2010-06-01 16:04:01 +00:00
parent ab54fd079f
commit 7f5d6a35d6
2 changed files with 11 additions and 23 deletions

View File

@ -51,13 +51,12 @@ struct taskqueue {
const char *tq_name;
taskqueue_enqueue_fn tq_enqueue;
void *tq_context;
struct task *tq_running;
struct mtx tq_mutex;
struct thread **tq_threads;
int tq_tcount;
int tq_spin;
int tq_flags;
int tq_tasks_running;
int tq_task_waiters;
};
#define TQ_FLAGS_ACTIVE (1 << 0)
@ -234,15 +233,14 @@ taskqueue_run(struct taskqueue *queue)
STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link);
pending = task->ta_pending;
task->ta_pending = 0;
queue->tq_tasks_running++;
queue->tq_running = task;
TQ_UNLOCK(queue);
task->ta_func(task->ta_context, pending);
TQ_LOCK(queue);
queue->tq_tasks_running--;
if (queue->tq_task_waiters > 0)
wakeup(task);
queue->tq_running = NULL;
wakeup(task);
}
/*
@ -258,21 +256,15 @@ taskqueue_drain(struct taskqueue *queue, struct task *task)
{
if (queue->tq_spin) { /* XXX */
mtx_lock_spin(&queue->tq_mutex);
while (task->ta_pending != 0 || queue->tq_tasks_running > 0) {
queue->tq_task_waiters++;
while (task->ta_pending != 0 || task == queue->tq_running)
msleep_spin(task, &queue->tq_mutex, "-", 0);
queue->tq_task_waiters--;
}
mtx_unlock_spin(&queue->tq_mutex);
} else {
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
mtx_lock(&queue->tq_mutex);
while (task->ta_pending != 0 || queue->tq_tasks_running > 0) {
queue->tq_task_waiters++;
while (task->ta_pending != 0 || task == queue->tq_running)
msleep(task, &queue->tq_mutex, PWAIT, "-", 0);
queue->tq_task_waiters--;
}
mtx_unlock(&queue->tq_mutex);
}
}

View File

@ -36,19 +36,15 @@
* taskqueue_run(). The first argument is taken from the 'ta_context'
* field of struct task and the second argument is a count of how many
* times the task was enqueued before the call to taskqueue_run().
*
* List of locks
* (c) const after init
* (q) taskqueue lock
*/
typedef void task_fn_t(void *context, int pending);
struct task {
STAILQ_ENTRY(task) ta_link; /* (q) link for queue */
u_short ta_pending; /* (q) count times queued */
u_short ta_priority; /* (c) Priority */
task_fn_t *ta_func; /* (c) task handler */
void *ta_context; /* (c) argument for handler */
STAILQ_ENTRY(task) ta_link; /* link for queue */
u_short ta_pending; /* count times queued */
u_short ta_priority; /* Priority */
task_fn_t *ta_func; /* task handler */
void *ta_context; /* argument for handler */
};
#endif /* !_SYS__TASK_H_ */