Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c95bde81
提交
c95bde81
9月 27, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
yank out stack overflow checking ugliness
上级
4f74de0e
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
2 行增加
和
14 行删除
+2
-14
main.c
main.c
+0
-1
proc.c
proc.c
+1
-5
proc.h
proc.h
+1
-4
swtch.S
swtch.S
+0
-4
没有找到文件。
main.c
浏览文件 @
c95bde81
...
@@ -60,7 +60,6 @@ mpmain(void)
...
@@ -60,7 +60,6 @@ mpmain(void)
if
(
cpu
()
!=
mp_bcpu
())
if
(
cpu
()
!=
mp_bcpu
())
lapic_init
(
cpu
());
lapic_init
(
cpu
());
setupsegs
(
0
);
setupsegs
(
0
);
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
;
popcli
();
popcli
();
...
...
proc.c
浏览文件 @
c95bde81
...
@@ -73,7 +73,7 @@ setupsegs(struct proc *p)
...
@@ -73,7 +73,7 @@ setupsegs(struct proc *p)
pushcli
();
pushcli
();
c
=
&
cpus
[
cpu
()];
c
=
&
cpus
[
cpu
()];
c
->
ts
.
ss0
=
SEG_
PROCSTACK
<<
3
;
c
->
ts
.
ss0
=
SEG_
KDATA
<<
3
;
if
(
p
)
if
(
p
)
c
->
ts
.
esp0
=
(
uint
)(
p
->
kstack
+
KSTACKSIZE
);
c
->
ts
.
esp0
=
(
uint
)(
p
->
kstack
+
KSTACKSIZE
);
else
else
...
@@ -84,15 +84,12 @@ setupsegs(struct proc *p)
...
@@ -84,15 +84,12 @@ setupsegs(struct proc *p)
c
->
gdt
[
SEG_KDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
0
);
c
->
gdt
[
SEG_KDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
0
);
c
->
gdt
[
SEG_TSS
]
=
SEG16
(
STS_T32A
,
(
uint
)
&
c
->
ts
,
sizeof
(
c
->
ts
)
-
1
,
0
);
c
->
gdt
[
SEG_TSS
]
=
SEG16
(
STS_T32A
,
(
uint
)
&
c
->
ts
,
sizeof
(
c
->
ts
)
-
1
,
0
);
c
->
gdt
[
SEG_TSS
].
s
=
0
;
c
->
gdt
[
SEG_TSS
].
s
=
0
;
c
->
gdt
[
SEG_CPUSTACK
]
=
SEG
(
STA_W
|
STA_E
,
0
,
(
uint
)
c
->
stack
,
0
);
if
(
p
){
if
(
p
){
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
(
uint
)
p
->
mem
,
p
->
sz
-
1
,
DPL_USER
);
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
(
uint
)
p
->
mem
,
p
->
sz
-
1
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
(
uint
)
p
->
mem
,
p
->
sz
-
1
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
(
uint
)
p
->
mem
,
p
->
sz
-
1
,
DPL_USER
);
c
->
gdt
[
SEG_PROCSTACK
]
=
SEG
(
STA_W
|
STA_E
,
0
,
(
uint
)
p
->
kstack
,
0
);
}
else
{
}
else
{
c
->
gdt
[
SEG_UCODE
]
=
SEG_NULL
;
c
->
gdt
[
SEG_UCODE
]
=
SEG_NULL
;
c
->
gdt
[
SEG_UDATA
]
=
SEG_NULL
;
c
->
gdt
[
SEG_UDATA
]
=
SEG_NULL
;
c
->
gdt
[
SEG_PROCSTACK
]
=
SEG_NULL
;
}
}
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
...
@@ -143,7 +140,6 @@ copyproc(struct proc *p)
...
@@ -143,7 +140,6 @@ copyproc(struct proc *p)
memset
(
&
np
->
context
,
0
,
sizeof
(
np
->
context
));
memset
(
&
np
->
context
,
0
,
sizeof
(
np
->
context
));
np
->
context
.
eip
=
(
uint
)
forkret
;
np
->
context
.
eip
=
(
uint
)
forkret
;
np
->
context
.
esp
=
(
uint
)
np
->
tf
;
np
->
context
.
esp
=
(
uint
)
np
->
tf
;
np
->
context
.
ss
=
SEG_PROCSTACK
<<
3
;
// Clear %eax so that fork system call returns 0 in child.
// Clear %eax so that fork system call returns 0 in child.
np
->
tf
->
eax
=
0
;
np
->
tf
->
eax
=
0
;
...
...
proc.h
浏览文件 @
c95bde81
...
@@ -4,9 +4,7 @@
...
@@ -4,9 +4,7 @@
#define SEG_UCODE 3
#define SEG_UCODE 3
#define SEG_UDATA 4
#define SEG_UDATA 4
#define SEG_TSS 5 // this process's task state
#define SEG_TSS 5 // this process's task state
#define SEG_CPUSTACK 6
#define NSEGS 6
#define SEG_PROCSTACK 7
#define NSEGS 8
// Saved registers for kernel context switches.
// Saved registers for kernel context switches.
// Don't need to save all the %fs etc. segment registers,
// Don't need to save all the %fs etc. segment registers,
...
@@ -24,7 +22,6 @@ struct context {
...
@@ -24,7 +22,6 @@ struct context {
int
esi
;
int
esi
;
int
edi
;
int
edi
;
int
ebp
;
int
ebp
;
int
ss
;
};
};
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
enum
proc_state
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
...
...
swtch.S
浏览文件 @
c95bde81
...
@@ -16,14 +16,10 @@ swtch:
...
@@ -16,14 +16,10 @@ swtch:
movl %esi, 20(%eax)
movl %esi, 20(%eax)
movl %edi, 24(%eax)
movl %edi, 24(%eax)
movl %ebp, 28(%eax)
movl %ebp, 28(%eax)
movl %ss, %ebx
movl %ebx, 32(%eax)
# Load new registers
# Load new registers
movl 4(%esp), %eax # not 8(%esp) - popped return address above
movl 4(%esp), %eax # not 8(%esp) - popped return address above
movl 32(%eax), %ebx
movl %ebx, %ss
movl 28(%eax), %ebp
movl 28(%eax), %ebp
movl 24(%eax), %edi
movl 24(%eax), %edi
movl 20(%eax), %esi
movl 20(%eax), %esi
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论