Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
47212719
Commit
47212719
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
use larger, allocated cpu stacks
parent
0fe118f3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.c
+15
-20
15 additions, 20 deletions
main.c
proc.h
+1
-3
1 addition, 3 deletions
proc.h
with
16 additions
and
23 deletions
main.c
+
15
−
20
View file @
47212719
...
...
@@ -6,13 +6,13 @@
#include
"x86.h"
static
void
bootothers
(
void
);
static
void
mpmain
(
void
)
__attribute__
((
noreturn
));
// Bootstrap processor starts running C code here.
int
main
(
void
)
{
int
i
;
static
volatile
int
bcpu
;
// cannot be on stack
int
bcpu
,
i
;
extern
char
edata
[],
end
[];
// clear BSS
...
...
@@ -20,15 +20,10 @@ main(void)
// splhi() every processor during bootstrap.
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
cpus
[
i
].
nsplhi
=
1
;
cpus
[
i
].
nsplhi
=
1
;
// no interrupts during bootstrap
mp_init
();
// collect info about this machine
bcpu
=
mp_bcpu
();
// Switch to bootstrap processor's stack
asm
volatile
(
"movl %0, %%esp"
:
:
"r"
(
cpus
[
bcpu
].
mpstack
+
MPSTACK
-
32
));
asm
volatile
(
"movl %0, %%ebp"
:
:
"r"
(
cpus
[
bcpu
].
mpstack
+
MPSTACK
));
lapic_init
(
bcpu
);
cprintf
(
"
\n
cpu%d: starting xv6
\n\n
"
,
cpu
());
...
...
@@ -38,34 +33,34 @@ main(void)
ioapic_init
();
// another interrupt controller
kinit
();
// physical memory allocator
tvinit
();
// trap vectors
idtinit
();
// interrupt descriptor table
fileinit
();
// file table
iinit
();
// inode cache
setupsegs
(
0
);
// segments & TSS
console_init
();
// I/O devices & their interrupts
ide_init
();
// disk
bootothers
();
// boot other CPUs
if
(
!
ismp
)
timer_init
();
// uniprocessor timer
cprintf
(
"ismp %d
\n
"
,
ismp
);
cprintf
(
"userinit
\n
"
);
userinit
();
// first user process
// enable interrupts on this processor.
spllo
();
// Allocate scheduler stacks and boot the other CPUs.
for
(
i
=
0
;
i
<
ncpu
;
i
++
)
cpus
[
i
].
stack
=
kalloc
(
KSTACKSIZE
);
bootothers
();
cprintf
(
"scheduler
\n
"
);
scheduler
();
// Switch to our scheduler stack and continue with mpmain.
asm
volatile
(
"movl %0, %%esp"
:
:
"r"
(
cpus
[
bcpu
].
stack
+
KSTACKSIZE
));
mpmain
();
}
// Additional processors start here.
static
void
mpmain
(
void
)
{
cprintf
(
"cpu%d:
start
in
g
\n
"
,
cpu
());
cprintf
(
"cpu%d:
mpma
in
\n
"
,
cpu
());
idtinit
();
lapic_init
(
cpu
());
if
(
cpu
()
!=
mp_bcpu
())
lapic_init
(
cpu
());
setupsegs
(
0
);
asm
volatile
(
"movl %0, %%ss"
::
"r"
(
SEG_CPUSTACK
<<
3
));
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier
cpus
[
cpu
()].
booted
=
1
;
spllo
();
...
...
@@ -89,7 +84,7 @@ bootothers(void)
continue
;
// Fill in %esp, %eip and start code on cpu.
*
(
void
**
)(
code
-
4
)
=
c
->
mp
stack
+
MP
STACK
;
*
(
void
**
)(
code
-
4
)
=
c
->
stack
+
K
STACK
SIZE
;
*
(
void
**
)(
code
-
8
)
=
mpmain
;
lapic_startap
(
c
->
apicid
,
(
uint
)
code
);
...
...
This diff is collapsed.
Click to expand it.
proc.h
+
1
−
3
View file @
47212719
...
...
@@ -49,8 +49,6 @@ struct proc {
// fixed-size stack
// expandable heap
#define MPSTACK 512
// Per-CPU state
struct
cpu
{
uchar
apicid
;
// Local APIC ID
...
...
@@ -58,7 +56,7 @@ struct cpu {
struct
context
context
;
// Switch here to enter scheduler
struct
taskstate
ts
;
// Used by x86 to find stack for interrupt
struct
segdesc
gdt
[
NSEGS
];
// x86 global descriptor table
char
mp
stack
[
MPSTACK
];
// Per-CPU startup stack
char
*
stack
;
volatile
int
booted
;
// Has the CPU started?
int
nsplhi
;
// Depth of splhi nesting.
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment