/* * Thread system initialization. */ void thread_bootstrap(void) { cpuarray_init(&allcpus); /* * Create the cpu structure for the bootup CPU, the one we're * currently running on. Assume the hardware number is 0; that * might be updated later by mainbus-type code. This also * creates a thread structure for the first thread, the one * that's already implicitly running when the kernel is * started from the bootloader. */ KASSERT(CURCPU_EXISTS() == false); (void)cpu_create(0); KASSERT(CURCPU_EXISTS() == true); /* cpu_create() should also have set t_proc. */ KASSERT(curcpu != NULL); KASSERT(curthread != NULL); KASSERT(curthread->t_proc != NULL); KASSERT(curthread->t_proc == kproc); /* Done */ }
/* * Thread system initialization. */ void thread_bootstrap(void) { struct cpu *bootcpu; struct thread *bootthread; cpuarray_init(&allcpus); /* * Create the cpu structure for the bootup CPU, the one we're * currently running on. Assume the hardware number is 0; that * might be updated later by mainbus-type code. This also * creates a thread structure for the first thread, the one * that's already implicitly running when the kernel is * started from the bootloader. */ bootcpu = cpu_create(0); bootthread = bootcpu->c_curthread; /* * Initializing curcpu and curthread is machine-dependent * because either of curcpu and curthread might be defined in * terms of the other. */ INIT_CURCPU(bootcpu, bootthread); /* * Now make sure both t_cpu and c_curthread are set. This * might be partially redundant with INIT_CURCPU depending on * how things are defined. */ curthread->t_cpu = curcpu; curcpu->c_curthread = curthread; /* cpu_create() should have set t_proc. */ KASSERT(curthread->t_proc != NULL); /* Initialize allwchans */ spinlock_init(&allwchans_lock); wchanarray_init(&allwchans); /* Done */ }