1/*- 2 * Copyright (c) 2000, All rights reserved. See /usr/src/COPYRIGHT 3 *
| 1/*- 2 * Copyright (c) 2000, All rights reserved. See /usr/src/COPYRIGHT 3 *
|
4 * $FreeBSD: head/sys/kern/kern_idle.c 72376 2001-02-12 00:20:08Z jake $
| 4 * $FreeBSD: head/sys/kern/kern_idle.c 76078 2001-04-27 19:28:25Z jhb $
|
5 */ 6 7#include "opt_ktrace.h" 8 9#include <sys/param.h> 10#include <sys/systm.h> 11#include <sys/proc.h> 12#include <sys/kernel.h> 13#include <sys/ktr.h> 14#include <sys/signalvar.h>
| 5 */ 6 7#include "opt_ktrace.h" 8 9#include <sys/param.h> 10#include <sys/systm.h> 11#include <sys/proc.h> 12#include <sys/kernel.h> 13#include <sys/ktr.h> 14#include <sys/signalvar.h>
|
| 15#include <sys/smp.h>
|
15#include <sys/resourcevar.h> 16#include <sys/vmmeter.h> 17#include <sys/sysctl.h> 18#include <sys/unistd.h> 19#include <sys/ipl.h> 20#include <sys/kthread.h> 21#include <sys/mutex.h> 22#include <sys/queue.h> 23#include <sys/eventhandler.h> 24#include <vm/vm.h> 25#include <vm/vm_extern.h> 26#ifdef KTRACE 27#include <sys/uio.h> 28#include <sys/ktrace.h> 29#endif 30 31#include <machine/cpu.h> 32#include <machine/md_var.h>
| 16#include <sys/resourcevar.h> 17#include <sys/vmmeter.h> 18#include <sys/sysctl.h> 19#include <sys/unistd.h> 20#include <sys/ipl.h> 21#include <sys/kthread.h> 22#include <sys/mutex.h> 23#include <sys/queue.h> 24#include <sys/eventhandler.h> 25#include <vm/vm.h> 26#include <vm/vm_extern.h> 27#ifdef KTRACE 28#include <sys/uio.h> 29#include <sys/ktrace.h> 30#endif 31 32#include <machine/cpu.h> 33#include <machine/md_var.h>
|
33#include <machine/smp.h>
| |
34 35#include <machine/globaldata.h> 36#include <machine/globals.h> 37 38static void idle_setup(void *dummy); 39SYSINIT(idle_setup, SI_SUB_SCHED_IDLE, SI_ORDER_FIRST, idle_setup, NULL) 40 41static void idle_proc(void *dummy); 42 43/* 44 * Setup per-cpu idle process contexts. The AP's shouldn't be running or 45 * accessing their idle processes at this point, so don't bother with 46 * locking. 47 */ 48static void 49idle_setup(void *dummy) 50{
| 34 35#include <machine/globaldata.h> 36#include <machine/globals.h> 37 38static void idle_setup(void *dummy); 39SYSINIT(idle_setup, SI_SUB_SCHED_IDLE, SI_ORDER_FIRST, idle_setup, NULL) 40 41static void idle_proc(void *dummy); 42 43/* 44 * Setup per-cpu idle process contexts. The AP's shouldn't be running or 45 * accessing their idle processes at this point, so don't bother with 46 * locking. 47 */ 48static void 49idle_setup(void *dummy) 50{
|
| 51#ifdef SMP
|
51 struct globaldata *gd;
| 52 struct globaldata *gd;
|
| 53#endif 54 struct proc *p;
|
52 int error; 53
| 55 int error; 56
|
54 SLIST_FOREACH(gd, &cpuhead, gd_allcpu) {
| |
55#ifdef SMP
| 57#ifdef SMP
|
56 error = kthread_create(idle_proc, NULL, &gd->gd_idleproc, 57 RFSTOPPED|RFHIGHPID, "idle: cpu%d", 58 gd->gd_cpuid);
| 58 SLIST_FOREACH(gd, &cpuhead, gd_allcpu) { 59 error = kthread_create(idle_proc, NULL, &p, 60 RFSTOPPED | RFHIGHPID, "idle: cpu%d", gd->gd_cpuid); 61 gd->gd_idleproc = p; 62 if (gd->gd_curproc == NULL) 63 gd->gd_curproc = p;
|
59#else
| 64#else
|
60 error = kthread_create(idle_proc, NULL, &gd->gd_idleproc, 61 RFSTOPPED|RFHIGHPID, "idle");
| 65 error = kthread_create(idle_proc, NULL, &p, 66 RFSTOPPED | RFHIGHPID, "idle"); 67 PCPU_SET(idleproc, p);
|
62#endif 63 if (error) 64 panic("idle_setup: kthread_create error %d\n", error); 65
| 68#endif 69 if (error) 70 panic("idle_setup: kthread_create error %d\n", error); 71
|
66 gd->gd_idleproc->p_flag |= P_NOLOAD; 67 gd->gd_idleproc->p_stat = SRUN; 68 if (gd->gd_curproc == NULL) 69 gd->gd_curproc = gd->gd_idleproc;
| 72 p->p_flag |= P_NOLOAD; 73 p->p_stat = SRUN; 74#ifdef SMP
|
70 }
| 75 }
|
| 76#endif
|
71} 72 73/* 74 * idle process context 75 */ 76static void 77idle_proc(void *dummy) 78{
--- 41 unchanged lines hidden --- | 77} 78 79/* 80 * idle process context 81 */ 82static void 83idle_proc(void *dummy) 84{
--- 41 unchanged lines hidden --- |