aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_kthread.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-04-25 13:35:38 +0000
committerMark Johnston <markj@FreeBSD.org>2024-04-25 13:35:38 +0000
commitd66399326cb4f89d1565fb62c1c07974886893c5 (patch)
treeeccda3056fd59c69810b88904f6dfff4db2b689c /sys/kern/kern_kthread.c
parent42255af64a5471a2668e3a0552d82639e1f70ee4 (diff)
downloadsrc-d66399326cb4f89d1565fb62c1c07974886893c5.tar.gz
src-d66399326cb4f89d1565fb62c1c07974886893c5.zip
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r--sys/kern/kern_kthread.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 8a84fd70918d..97d10fdb394a 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -495,13 +495,21 @@ kproc_kthread_add(void (*func)(void *), void *arg,
struct thread *td;
if (*procptr == NULL) {
+ /*
+ * Use RFSTOPPED to ensure that *tdptr is initialized before the
+ * thread starts running.
+ */
error = kproc_create(func, arg,
- procptr, flags, pages, "%s", procname);
+ procptr, flags | RFSTOPPED, pages, "%s", procname);
if (error)
return (error);
td = FIRST_THREAD_IN_PROC(*procptr);
if (tdptr)
*tdptr = td;
+ if ((flags & RFSTOPPED) == 0) {
+ thread_lock(td);
+ sched_add(td, SRQ_BORING);
+ }
va_start(ap, fmt);
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
va_end(ap);