Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
3807c1f2
提交
3807c1f2
9月 27, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename splhi/spllo to pushcli/popcli
上级
39c3fb1b
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
22 行增加
和
22 行删除
+22
-22
defs.h
defs.h
+2
-2
main.c
main.c
+3
-3
proc.c
proc.c
+5
-5
proc.h
proc.h
+1
-1
spinlock.c
spinlock.c
+9
-9
trap.c
trap.c
+2
-2
没有找到文件。
defs.h
浏览文件 @
3807c1f2
...
@@ -115,8 +115,8 @@ void getcallerpcs(void*, uint*);
...
@@ -115,8 +115,8 @@ void getcallerpcs(void*, uint*);
int
holding
(
struct
spinlock
*
);
int
holding
(
struct
spinlock
*
);
void
initlock
(
struct
spinlock
*
,
char
*
);
void
initlock
(
struct
spinlock
*
,
char
*
);
void
release
(
struct
spinlock
*
);
void
release
(
struct
spinlock
*
);
void
splh
i
();
void
pushcl
i
();
void
spllo
();
void
popcli
();
// string.c
// string.c
int
memcmp
(
const
void
*
,
const
void
*
,
uint
);
int
memcmp
(
const
void
*
,
const
void
*
,
uint
);
...
...
main.c
浏览文件 @
3807c1f2
...
@@ -18,9 +18,9 @@ main(void)
...
@@ -18,9 +18,9 @@ main(void)
// clear BSS
// clear BSS
memset
(
edata
,
0
,
end
-
edata
);
memset
(
edata
,
0
,
end
-
edata
);
//
splh
i() every processor during bootstrap.
//
pushcl
i() every processor during bootstrap.
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
cpus
[
i
].
n
splh
i
=
1
;
// no interrupts during bootstrap
cpus
[
i
].
n
cl
i
=
1
;
// no interrupts during bootstrap
mp_init
();
// collect info about this machine
mp_init
();
// collect info about this machine
bcpu
=
mp_bcpu
();
bcpu
=
mp_bcpu
();
...
@@ -63,7 +63,7 @@ mpmain(void)
...
@@ -63,7 +63,7 @@ mpmain(void)
asm
volatile
(
"movl %0, %%ss"
::
"r"
(
SEG_CPUSTACK
<<
3
));
asm
volatile
(
"movl %0, %%ss"
::
"r"
(
SEG_CPUSTACK
<<
3
));
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier
cpus
[
cpu
()].
booted
=
1
;
cpus
[
cpu
()].
booted
=
1
;
spllo
();
popcli
();
scheduler
();
scheduler
();
}
}
...
...
proc.c
浏览文件 @
3807c1f2
...
@@ -71,7 +71,7 @@ setupsegs(struct proc *p)
...
@@ -71,7 +71,7 @@ setupsegs(struct proc *p)
{
{
struct
cpu
*
c
;
struct
cpu
*
c
;
splh
i
();
pushcl
i
();
c
=
&
cpus
[
cpu
()];
c
=
&
cpus
[
cpu
()];
c
->
ts
.
ss0
=
SEG_PROCSTACK
<<
3
;
c
->
ts
.
ss0
=
SEG_PROCSTACK
<<
3
;
if
(
p
)
if
(
p
)
...
@@ -97,7 +97,7 @@ setupsegs(struct proc *p)
...
@@ -97,7 +97,7 @@ setupsegs(struct proc *p)
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
ltr
(
SEG_TSS
<<
3
);
ltr
(
SEG_TSS
<<
3
);
spllo
();
popcli
();
}
}
// Create a new process copying p as the parent.
// Create a new process copying p as the parent.
...
@@ -189,9 +189,9 @@ curproc(void)
...
@@ -189,9 +189,9 @@ curproc(void)
{
{
struct
proc
*
p
;
struct
proc
*
p
;
splh
i
();
pushcl
i
();
p
=
cpus
[
cpu
()].
curproc
;
p
=
cpus
[
cpu
()].
curproc
;
spllo
();
popcli
();
return
p
;
return
p
;
}
}
...
@@ -249,7 +249,7 @@ sched(void)
...
@@ -249,7 +249,7 @@ sched(void)
panic
(
"sched running"
);
panic
(
"sched running"
);
if
(
!
holding
(
&
proc_table_lock
))
if
(
!
holding
(
&
proc_table_lock
))
panic
(
"sched proc_table_lock"
);
panic
(
"sched proc_table_lock"
);
if
(
cpus
[
cpu
()].
n
splh
i
!=
1
)
if
(
cpus
[
cpu
()].
n
cl
i
!=
1
)
panic
(
"sched locks"
);
panic
(
"sched locks"
);
swtch
(
&
cp
->
context
,
&
cpus
[
cpu
()].
context
);
swtch
(
&
cp
->
context
,
&
cpus
[
cpu
()].
context
);
...
...
proc.h
浏览文件 @
3807c1f2
...
@@ -61,7 +61,7 @@ struct cpu {
...
@@ -61,7 +61,7 @@ struct cpu {
struct
segdesc
gdt
[
NSEGS
];
// x86 global descriptor table
struct
segdesc
gdt
[
NSEGS
];
// x86 global descriptor table
char
*
stack
;
char
*
stack
;
volatile
int
booted
;
// Has the CPU started?
volatile
int
booted
;
// Has the CPU started?
int
n
splhi
;
// Depth of splh
i nesting.
int
n
cli
;
// Depth of pushcl
i nesting.
};
};
extern
struct
cpu
cpus
[
NCPU
];
extern
struct
cpu
cpus
[
NCPU
];
...
...
spinlock.c
浏览文件 @
3807c1f2
...
@@ -25,7 +25,7 @@ initlock(struct spinlock *lock, char *name)
...
@@ -25,7 +25,7 @@ initlock(struct spinlock *lock, char *name)
void
void
acquire
(
struct
spinlock
*
lock
)
acquire
(
struct
spinlock
*
lock
)
{
{
splh
i
();
pushcl
i
();
if
(
holding
(
lock
))
if
(
holding
(
lock
))
panic
(
"acquire"
);
panic
(
"acquire"
);
...
@@ -59,7 +59,7 @@ release(struct spinlock *lock)
...
@@ -59,7 +59,7 @@ release(struct spinlock *lock)
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier (see Ch 7, IA-32 manual vol 3)
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier (see Ch 7, IA-32 manual vol 3)
lock
->
locked
=
0
;
lock
->
locked
=
0
;
spllo
();
popcli
();
}
}
// Record the current call stack in pcs[] by following the %ebp chain.
// Record the current call stack in pcs[] by following the %ebp chain.
...
@@ -93,20 +93,20 @@ holding(struct spinlock *lock)
...
@@ -93,20 +93,20 @@ holding(struct spinlock *lock)
// Better names? Better functions?
// Better names? Better functions?
void
void
splh
i
(
void
)
pushcl
i
(
void
)
{
{
cli
();
cli
();
cpus
[
cpu
()].
n
splh
i
++
;
cpus
[
cpu
()].
n
cl
i
++
;
}
}
void
void
spllo
(
void
)
popcli
(
void
)
{
{
if
(
read_eflags
()
&
FL_IF
)
if
(
read_eflags
()
&
FL_IF
)
panic
(
"
spllo
- interruptible"
);
panic
(
"
popcli
- interruptible"
);
if
(
--
cpus
[
cpu
()].
n
splh
i
<
0
)
if
(
--
cpus
[
cpu
()].
n
cl
i
<
0
)
panic
(
"
spllo
"
);
panic
(
"
popcli
"
);
if
(
cpus
[
cpu
()].
n
splh
i
==
0
)
if
(
cpus
[
cpu
()].
n
cl
i
==
0
)
sti
();
sti
();
}
}
trap.c
浏览文件 @
3807c1f2
...
@@ -45,7 +45,7 @@ trap(struct trapframe *tf)
...
@@ -45,7 +45,7 @@ trap(struct trapframe *tf)
}
}
// No interrupts during interrupt handling.
// No interrupts during interrupt handling.
splh
i
();
pushcl
i
();
switch
(
tf
->
trapno
){
switch
(
tf
->
trapno
){
case
IRQ_OFFSET
+
IRQ_TIMER
:
case
IRQ_OFFSET
+
IRQ_TIMER
:
...
@@ -84,7 +84,7 @@ trap(struct trapframe *tf)
...
@@ -84,7 +84,7 @@ trap(struct trapframe *tf)
cp
->
killed
=
1
;
cp
->
killed
=
1
;
}
}
spllo
();
popcli
();
// Force process exit if it has been killed and is in user space.
// Force process exit if it has been killed and is in user space.
// (If it is still executing in the kernel, let it keep running
// (If it is still executing in the kernel, let it keep running
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论