Added a global variable for the number of cpus

This commit is contained in:
Scott Haseley 2016-03-25 11:11:08 -04:00
parent 25a1d7debc
commit 501773f90e
2 changed files with 4 additions and 1 deletions

View File

@ -35,6 +35,7 @@
#include <threadlist.h>
#include <machine/vm.h> /* for TLBSHOOTDOWN_MAX */
extern unsigned num_cpus;
/*
* Per-cpu structure

View File

@ -65,6 +65,7 @@ struct wchan {
DECLARRAY(cpu, static __UNUSED inline);
DEFARRAY(cpu, static __UNUSED inline);
static struct cpuarray allcpus;
unsigned num_cpus;
/* Used to wait for secondary CPUs to come online. */
static struct semaphore *cpu_startup_sem;
@ -426,7 +427,8 @@ thread_start_cpus(void)
cpu_startup_sem = sem_create("cpu_hatch", 0);
mainbus_start_cpus();
for (i=0; i<cpuarray_num(&allcpus) - 1; i++) {
num_cpus = cpuarray_num(&allcpus);
for (i=0; i<num_cpus - 1; i++) {
P(cpu_startup_sem);
}
sem_destroy(cpu_startup_sem);