Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
47212719
提交
47212719
9月 27, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use larger, allocated cpu stacks
上级
0fe118f3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
23 行删除
+16
-23
main.c
main.c
+15
-20
proc.h
proc.h
+1
-3
没有找到文件。
main.c
浏览文件 @
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:
starting
\n
"
,
cpu
());
cprintf
(
"cpu%d:
mpmain
\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
->
mpstack
+
MPSTACK
;
*
(
void
**
)(
code
-
4
)
=
c
->
stack
+
KSTACKSIZE
;
*
(
void
**
)(
code
-
8
)
=
mpmain
;
lapic_startap
(
c
->
apicid
,
(
uint
)
code
);
...
...
proc.h
浏览文件 @
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
mpstack
[
MPSTACK
];
// Per-CPU startup stack
char
*
stack
;
volatile
int
booted
;
// Has the CPU started?
int
nsplhi
;
// Depth of splhi nesting.
};
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论