Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
1403faf4
提交
1403faf4
5月 02, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pull proclock apart: condition vars, per process lock, runq lock
Passes forktest w. 2 CPUs
上级
3bf5e592
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
164 行增加
和
87 行删除
+164
-87
proc.c
proc.c
+140
-83
proc.h
proc.h
+15
-0
spinlock.c
spinlock.c
+6
-2
vm.c
vm.c
+3
-2
没有找到文件。
proc.c
浏览文件 @
1403faf4
差异被折叠。
点击展开。
proc.h
浏览文件 @
1403faf4
...
...
@@ -45,6 +45,7 @@ struct proc {
struct
file
*
ofile
[
NOFILE
];
// Open files
struct
inode
*
cwd
;
// Current directory
char
name
[
16
];
// Process name (debugging)
struct
spinlock
lock
;
struct
proc
*
next
;
};
...
...
@@ -69,6 +70,18 @@ struct cpu {
struct
proc
*
proc
;
// The currently-running process.
struct
ptable
*
ptable
;
// The per-core proc table
struct
kmem
*
kmem
;
// The per-core proc table
struct
runq
*
runq
;
// The per-core proc table
};
struct
condvar
{
void
*
chan
;
// If non-zero, sleeping on chan
struct
proc
*
waiters
;
};
struct
runq
{
char
name
[
MAXNAME
];
struct
spinlock
lock
;
struct
proc
*
runq
;
};
struct
ptable
{
...
...
@@ -80,6 +93,7 @@ struct ptable {
extern
struct
ptable
ptables
[
NCPU
];
extern
struct
cpu
cpus
[
NCPU
];
extern
struct
runq
runqs
[
NCPU
];
extern
int
ncpu
;
// Per-CPU variables, holding pointers to the
...
...
@@ -94,3 +108,4 @@ extern struct cpu *cpu asm("%gs:0"); // &cpus[cpunum()]
extern
struct
proc
*
proc
asm
(
"%gs:4"
);
// cpus[cpunum()].proc
extern
struct
ptable
*
ptable
asm
(
"%gs:8"
);
// &ptables[cpunum()]
extern
struct
kmem
*
kmem
asm
(
"%gs:12"
);
// &kmems[cpunum()]
extern
struct
runq
*
runq
asm
(
"%gs:16"
);
// &runqs[cpunum()]
spinlock.c
浏览文件 @
1403faf4
...
...
@@ -24,8 +24,10 @@ void
acquire
(
struct
spinlock
*
lk
)
{
pushcli
();
// disable interrupts to avoid deadlock.
if
(
holding
(
lk
))
if
(
holding
(
lk
))
{
cprintf
(
"lock: %s
\n
"
,
lk
->
name
);
panic
(
"acquire"
);
}
// The xchg is atomic.
// It also serializes, so that reads after acquire are not
...
...
@@ -42,8 +44,10 @@ acquire(struct spinlock *lk)
void
release
(
struct
spinlock
*
lk
)
{
if
(
!
holding
(
lk
))
if
(
!
holding
(
lk
))
{
cprintf
(
"lock: %s
\n
"
,
lk
->
name
);
panic
(
"release"
);
}
lk
->
pcs
[
0
]
=
0
;
lk
->
cpu
=
0
;
...
...
vm.c
浏览文件 @
1403faf4
...
...
@@ -37,8 +37,8 @@ seginit(void)
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
DPL_USER
);
// Map cpu, curproc, ptable, kmem
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
16
,
0
);
// Map cpu, curproc, ptable, kmem
, runq
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
20
,
0
);
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
loadgs
(
SEG_KCPU
<<
3
);
...
...
@@ -48,6 +48,7 @@ seginit(void)
proc
=
0
;
ptable
=
&
ptables
[
cpunum
()];
kmem
=
&
kmems
[
cpunum
()];
runq
=
&
runqs
[
cpunum
()];
}
// Return the address of the PTE in page table pgdir
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论