diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-08 06:56:15 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-08 06:56:15 +0000 |
commit | dde526c68755ad09766970f6ed0bbe91615eedf0 (patch) | |
tree | df961ee6ec262126c84e338e90163e8dac0f53c2 /sys/kern | |
parent | 43b83dbfb1ff2497faad39b5321872032bba6b56 (diff) |
Have kthread_create_deferred() act immediately once kthread_run_deferred_queue()
has been invoked; forgotten part of the ``create init earlier'' changes.
From NetBSD as well.
ok deraadt@ dlg@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_kthread.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 721c440c999..971d5e76eb6 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -1,8 +1,8 @@ -/* $OpenBSD: kern_kthread.c,v 1.23 2004/11/23 19:08:55 miod Exp $ */ +/* $OpenBSD: kern_kthread.c,v 1.24 2004/12/08 06:56:14 miod Exp $ */ /* $NetBSD: kern_kthread.c,v 1.3 1998/12/22 21:21:36 kleink Exp $ */ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -56,6 +56,8 @@ */ #include <sys/stdarg.h> +int kthread_create_now; + /* * Fork a kernel thread. Any process can request this to be done. * The VM space and limits, etc. will be shared with proc0. @@ -139,6 +141,11 @@ kthread_create_deferred(void (*func)(void *), void *arg) { struct kthread_q *kq; + if (kthread_create_now) { + (*func)(arg); + return; + } + kq = malloc(sizeof *kq, M_TEMP, M_NOWAIT); if (kq == NULL) panic("unable to allocate kthread_q"); @@ -155,6 +162,9 @@ kthread_run_deferred_queue(void) { struct kthread_q *kq; + /* No longer need to defer kthread creation. */ + kthread_create_now = 1; + while ((kq = SIMPLEQ_FIRST(&kthread_q)) != NULL) { SIMPLEQ_REMOVE_HEAD(&kthread_q, kq_q); (*kq->kq_func)(kq->kq_arg); |