PERFORCE change 139544 for review
Sam Leffler
sam at FreeBSD.org
Mon Apr 7 21:24:18 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=139544
Change 139544 by sam at sam_ebb on 2008/04/07 21:23:17
change taskqueue_start_threads to create threads of proc0 instead
of procs; note this means these are no longer visible (by default)
in ps, top, etc.
Affected files ...
.. //depot/projects/vap/sys/kern/subr_taskqueue.c#7 edit
Differences ...
==== //depot/projects/vap/sys/kern/subr_taskqueue.c#7 (text+ko) ====
@@ -56,8 +56,8 @@
void *tq_context;
struct task *tq_running;
struct mtx tq_mutex;
- struct proc **tq_pproc;
- int tq_pcount;
+ struct thread **tq_threads;
+ int tq_tcount;
int tq_spin;
int tq_flags;
};
@@ -143,10 +143,10 @@
* Signal a taskqueue thread to terminate.
*/
static void
-taskqueue_terminate(struct proc **pp, struct taskqueue *tq)
+taskqueue_terminate(struct thread **pp, struct taskqueue *tq)
{
- while (tq->tq_pcount > 0) {
+ while (tq->tq_tcount > 0) {
wakeup(tq);
TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0);
}
@@ -163,9 +163,9 @@
TQ_LOCK(queue);
queue->tq_flags &= ~TQ_FLAGS_ACTIVE;
taskqueue_run(queue);
- taskqueue_terminate(queue->tq_pproc, queue);
+ taskqueue_terminate(queue->tq_threads, queue);
mtx_destroy(&queue->tq_mutex);
- free(queue->tq_pproc, M_TASKQUEUE);
+ free(queue->tq_threads, M_TASKQUEUE);
free(queue, M_TASKQUEUE);
}
@@ -341,45 +341,47 @@
const char *name, ...)
{
va_list ap;
+ struct thread *td;
struct taskqueue *tq;
- struct thread *td;
+ int i, error;
char ktname[MAXCOMLEN];
- int i, error;
if (count <= 0)
return (EINVAL);
+
tq = *tqp;
va_start(ap, name);
vsnprintf(ktname, MAXCOMLEN, name, ap);
va_end(ap);
- tq->tq_pproc = malloc(sizeof(struct proc *) * count, M_TASKQUEUE,
+ tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE,
M_NOWAIT | M_ZERO);
- if (tq->tq_pproc == NULL) {
+ if (tq->tq_threads == NULL) {
printf("%s: no memory for %s threads\n", __func__, ktname);
return (ENOMEM);
}
for (i = 0; i < count; i++) {
if (count == 1)
- error = kproc_create(taskqueue_thread_loop, tqp,
- &tq->tq_pproc[i], RFSTOPPED, 0, ktname);
+ error = kthread_add(taskqueue_thread_loop, tqp, NULL,
+ &tq->tq_threads[i], RFSTOPPED, 0, ktname);
else
- error = kproc_create(taskqueue_thread_loop, tqp,
- &tq->tq_pproc[i], RFSTOPPED, 0, "%s_%d", ktname, i);
+ error = kthread_add(taskqueue_thread_loop, tqp, NULL,
+ &tq->tq_threads[i], RFSTOPPED, 0,
+ "%s_%d", ktname, i);
if (error) {
/* should be ok to continue, taskqueue_free will dtrt */
- printf("%s: kproc_create(%s): error %d",
- __func__, ktname, error);
- tq->tq_pproc[i] = NULL; /* paranoid */
+ printf("%s: kthread_add(%s): error %d", __func__,
+ ktname, error);
+ tq->tq_threads[i] = NULL; /* paranoid */
} else
- tq->tq_pcount++;
+ tq->tq_tcount++;
}
for (i = 0; i < count; i++) {
- if (tq->tq_pproc[i] == NULL)
+ if (tq->tq_threads[i] == NULL)
continue;
- td = FIRST_THREAD_IN_PROC(tq->tq_pproc[i]);
+ td = tq->tq_threads[i];
thread_lock(td);
sched_prio(td, pri);
sched_add(td, SRQ_BORING);
@@ -403,8 +405,8 @@
} while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0);
/* rendezvous with thread that asked us to terminate */
- tq->tq_pcount--;
- wakeup_one(tq->tq_pproc);
+ tq->tq_tcount--;
+ wakeup_one(tq->tq_threads);
TQ_UNLOCK(tq);
kproc_exit(0);
}
More information about the p4-projects
mailing list