/*
 * Start up secondary cpus. Called from boot().
 */
void
thread_start_cpus(void)
{
    char buf[64];
    unsigned i;

    cpu_identify(buf, sizeof(buf));
    kprintf("cpu0: %s\n", buf);

    cpu_startup_sem = sem_create("cpu_hatch", 0);
    thread_count_wchan = wchan_create("thread_count");
    mainbus_start_cpus();

    num_cpus = cpuarray_num(&allcpus);
    for (i=0; i<num_cpus - 1; i++) {
        P(cpu_startup_sem);
    }
    sem_destroy(cpu_startup_sem);
    if (i == 0) {
        kprintf("1 CPU online\n");
    } else {
        kprintf("%d CPUs online\n", i + 1);
    }
    cpu_startup_sem = NULL;

    // Gross hack to deal with os/161 "idle" threads. Hardcode the thread count
    // to 1 so the inc/dec properly works in thread_[fork/exit]. The one thread
    // is the cpu0 boot thread (menu), which is the only thread that hasn't
    // exited yet.
    thread_count = 1;
}
Пример #2
0
/*
 * Start up secondary cpus. Called from boot().
 */
void
thread_start_cpus(void)
{
	char buf[64];
	unsigned i;

	cpu_identify(buf, sizeof(buf));
	kprintf("cpu0: %s\n", buf);

	cpu_startup_sem = sem_create("cpu_hatch", 0);
	mainbus_start_cpus();

	for (i=0; i<cpuarray_num(&allcpus) - 1; i++) {
		P(cpu_startup_sem);
	}
	sem_destroy(cpu_startup_sem);
	cpu_startup_sem = NULL;
}