From dde526c68755ad09766970f6ed0bbe91615eedf0 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 8 Dec 2004 06:56:15 +0000 Subject: 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@ --- sys/kern/kern_kthread.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sys/kern/kern_kthread.c') 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 +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); -- cgit v1.2.3