Skip to content

Commit

Permalink
Added a global variable for the number of cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
shaseley committed Mar 25, 2016
1 parent 25a1d7d commit 501773f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions kern/include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <threadlist.h>
#include <machine/vm.h> /* for TLBSHOOTDOWN_MAX */

extern unsigned num_cpus;

/*
* Per-cpu structure
Expand Down
4 changes: 3 additions & 1 deletion kern/thread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 501773f

Please sign in to comment.