From 501773f90ed96fc07f357d680a4479bcbfe677c5 Mon Sep 17 00:00:00 2001 From: Scott Haseley Date: Fri, 25 Mar 2016 11:11:08 -0400 Subject: [PATCH] Added a global variable for the number of cpus --- kern/include/cpu.h | 1 + kern/thread/thread.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kern/include/cpu.h b/kern/include/cpu.h index 994f3c1..787c6cf 100644 --- a/kern/include/cpu.h +++ b/kern/include/cpu.h @@ -35,6 +35,7 @@ #include #include /* for TLBSHOOTDOWN_MAX */ +extern unsigned num_cpus; /* * Per-cpu structure diff --git a/kern/thread/thread.c b/kern/thread/thread.c index ae252e4..7a06d07 100644 --- a/kern/thread/thread.c +++ b/kern/thread/thread.c @@ -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