aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_idle.c
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>2007-10-26 08:00:41 +0000
committerJulian Elischer <julian@FreeBSD.org>2007-10-26 08:00:41 +0000
commit7ab24ea3b9c35b2ff5e1e575111699e501ef203a (patch)
treee047e33390a9aae820357c54ff8602bc8faad475 /sys/kern/kern_idle.c
parentc47b138a96ddc99079eedf58c9d91465e64fceae (diff)
downloadsrc-7ab24ea3b9c35b2ff5e1e575111699e501ef203a.tar.gz
src-7ab24ea3b9c35b2ff5e1e575111699e501ef203a.zip
Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create() plus a pointer to a process structure, and adds a kernel thread to that process. kproc_kthread_add() takes the parameters for kthread_add, plus a process name and a pointer to a pointer to a process instead of just a pointer, and if the proc * is NULL, it creates the process to the specifications required, before adding the thread to it. All other old kthread_xxx() calls return, but act on (struct thread *) instead of (struct proc *). One reason to change the name is so that any old kernel modules that are lying around and expect kthread_create() to make a process will not just accidentally link. fix top to show kernel threads by their thread name in -SH mode add a tdnam formatting option to ps to show thread names. make all idle threads actual kthreads and put them into their own idled process. make all interrupt threads kthreads and put them in an interd process (mainly for aesthetic and accounting reasons) rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper' man page fixes to follow.
Notes
Notes: svn path=/head/; revision=173004
Diffstat (limited to 'sys/kern/kern_idle.c')
-rw-r--r--sys/kern/kern_idle.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c
index 43ce37a2faee..c875e8592a43 100644
--- a/sys/kern/kern_idle.c
+++ b/sys/kern/kern_idle.c
@@ -60,27 +60,25 @@ idle_setup(void *dummy)
#ifdef SMP
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
- error = kproc_create(sched_idletd, NULL, &p,
- RFSTOPPED | RFHIGHPID, 0, "idle: cpu%d", pc->pc_cpuid);
- pc->pc_idlethread = FIRST_THREAD_IN_PROC(p);
+#endif
+ error = kproc_kthread_add(sched_idletd, NULL, &p, &td,
+ RFSTOPPED | RFHIGHPID, 0, "idled", "idle: cpu%d", pc->pc_cpuid);
+#ifdef SMP
+ pc->pc_idlethread = td;
#else
- error = kproc_create(sched_idletd, NULL, &p,
- RFSTOPPED | RFHIGHPID, 0, "idle");
- PCPU_SET(idlethread, FIRST_THREAD_IN_PROC(p));
+ PCPU_SET(idlethread, td);
#endif
+ p = td->td_proc;
if (error)
panic("idle_setup: kproc_create error %d\n", error);
- PROC_LOCK(p);
p->p_flag |= P_NOLOAD;
- td = FIRST_THREAD_IN_PROC(p);
thread_lock(td);
TD_SET_CAN_RUN(td);
td->td_flags |= TDF_IDLETD;
sched_class(td, PRI_IDLE);
sched_prio(td, PRI_MAX_IDLE);
thread_unlock(td);
- PROC_UNLOCK(p);
#ifdef SMP
}
#endif