Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
b74f4b57
提交
b74f4b57
7月 16, 2006
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Keep interrupts disabled during startup.
上级
ef2bd07a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
19 行删除
+32
-19
main.c
main.c
+27
-16
mp.c
mp.c
+3
-1
spinlock.c
spinlock.c
+2
-2
没有找到文件。
main.c
浏览文件 @
b74f4b57
...
...
@@ -11,36 +11,30 @@
#include "spinlock.h"
extern
char
edata
[],
end
[];
extern
int
acpu
;
extern
uint8_t
_binary_user1_start
[],
_binary_user1_size
[];
extern
uint8_t
_binary_usertests_start
[],
_binary_usertests_size
[];
extern
uint8_t
_binary_userfs_start
[],
_binary_userfs_size
[];
extern
int
use_console_lock
;
struct
spinlock
sillylock
;
// hold this to keep interrupts disabled
// CPU 0 starts running C code here.
int
main
()
{
int
i
;
struct
proc
*
p
;
if
(
acpu
)
{
cprintf
(
"an application processor
\n
"
);
idtinit
();
// CPU's idt
lapic_init
(
cpu
());
lapic_timerinit
();
lapic_enableintr
();
scheduler
();
}
acpu
=
1
;
// clear BSS
memset
(
edata
,
0
,
end
-
edata
);
// Make sure interrupts stay disabled on all processors
// until each signals it is ready, by pretending to hold
// an extra lock.
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
cpus
[
i
].
nlock
++
;
mp_init
();
// collect info about this machine
acquire
(
&
sillylock
);
use_console_lock
=
1
;
lapic_init
(
mp_bcpu
());
...
...
@@ -78,7 +72,8 @@ main()
// init disk device
//ide_init();
// become interruptable
// Enable interrupts on this processor.
cpus
[
cpu
()].
nlock
--
;
sti
();
p
=
copyproc
(
&
proc
[
0
]);
...
...
@@ -87,13 +82,29 @@ main()
//load_icode(p, _binary_userfs_start, (unsigned) _binary_userfs_size);
p
->
state
=
RUNNABLE
;
cprintf
(
"loaded userfs
\n
"
);
release
(
&
sillylock
);
scheduler
();
return
0
;
}
// Additional processors start here.
int
mpmain
(
void
)
{
cprintf
(
"an application processor
\n
"
);
idtinit
();
// CPU's idt
lapic_init
(
cpu
());
lapic_timerinit
();
lapic_enableintr
();
// Enable interrupts on this processor.
cpus
[
cpu
()].
nlock
--
;
sti
();
scheduler
();
}
void
load_icode
(
struct
proc
*
p
,
uint8_t
*
binary
,
unsigned
size
)
{
...
...
mp.c
浏览文件 @
b74f4b57
...
...
@@ -191,6 +191,8 @@ mp_bcpu(void)
return
bcpu
-
cpus
;
}
extern
void
mpmain
(
void
);
void
mp_startthem
()
{
...
...
@@ -205,7 +207,7 @@ mp_startthem()
if
(
c
==
cpu
())
continue
;
cprintf
(
"starting processor %d
\n
"
,
c
);
*
(
unsigned
*
)(
APBOOTCODE
-
4
)
=
(
unsigned
)
(
cpus
[
c
].
mpstack
)
+
MPSTACK
;
// tell it what to use for %esp
*
(
unsigned
*
)(
APBOOTCODE
-
8
)
=
(
unsigned
)
&
main
;
// tell it where to jump to
*
(
unsigned
*
)(
APBOOTCODE
-
8
)
=
(
unsigned
)
mp
main
;
// tell it where to jump to
lapic_startap
(
cpus
[
c
].
apicid
,
(
uint32_t
)
APBOOTCODE
);
}
}
spinlock.c
浏览文件 @
b74f4b57
...
...
@@ -10,7 +10,7 @@
// because cprintf uses them itself.
#define cprintf dont_use_cprintf
extern
int
bootstrap
;
extern
int
use_console_lock
;
int
getcallerpc
(
void
*
v
)
...
...
@@ -34,7 +34,7 @@ release(struct spinlock * lock)
{
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier
lock
->
locked
=
0
;
if
(
--
cpus
[
cpu
()].
nlock
==
0
&&
!
bootstrap
)
if
(
--
cpus
[
cpu
()].
nlock
==
0
)
sti
();
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论