summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorAlmuHS <almuhs@github.com>2019-04-15 14:27:40 +0200
committerAlmuHS <almuhs@github.com>2019-04-15 14:27:40 +0200
commit40587d2b46557c4e158c50ee37f3ab9b622d8981 (patch)
tree77dabc16e7e752303be268361ceb80195d6879bd /kern
parent413d641251aec4a6db87441934322d6862512818 (diff)
rewritten cpu_number
Diffstat (limited to 'kern')
-rw-r--r--kern/cpu_number.c16
-rw-r--r--kern/cpu_number.h13
2 files changed, 16 insertions, 13 deletions
diff --git a/kern/cpu_number.c b/kern/cpu_number.c
index 8bac9117..f8315139 100644
--- a/kern/cpu_number.c
+++ b/kern/cpu_number.c
@@ -9,13 +9,15 @@ int
cpu_number()
{
if(ncpu == 1 | lapic == 0) return 0;
- else{
+ else{
unsigned apic_id = lapic->apic_id.r >>24;
- int i = 0;
-
- while(i< ncpu && machine_slot[i].apic_id != apic_id) i++;
-
- if(i == ncpu) return -1;
- else return i;
+ int kernel_id;
+//
+// while(i< ncpu && machine_slot[i].apic_id != apic_id) i++;
+
+ kernel_id = apic2kernel[apic_id];
+
+// if(i == ncpu) return -1;
+ return kernel_id;
}
}
diff --git a/kern/cpu_number.h b/kern/cpu_number.h
index 16d03b80..0d24525a 100644
--- a/kern/cpu_number.h
+++ b/kern/cpu_number.h
@@ -1,25 +1,25 @@
-/*
+/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
- *
+ *
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
- *
+ *
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
+ *
* Carnegie Mellon requests users of this software to return to
- *
+ *
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
- *
+ *
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
@@ -34,6 +34,7 @@
*/
extern unsigned int master_cpu; /* 'master' processor - keeps time */
+extern unsigned apic2kernel[NCPUS];
#if (NCPUS == 1)
/* cpu number is always 0 on a single processor system */