Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
cd61c6de
提交
cd61c6de
5月 25, 2011
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'scale' of
git+ssh://pdos.csail.mit.edu/home/am0/6.828/xv6
into scale
上级
8cb44655
326974a8
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
36 行删除
+10
-36
proc.c
proc.c
+1
-11
proc.h
proc.h
+2
-13
vm.c
vm.c
+7
-12
没有找到文件。
proc.c
浏览文件 @
cd61c6de
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
#include "proc.h"
#include "proc.h"
#include "xv6-mtrace.h"
#include "xv6-mtrace.h"
struct
ptable
ptables
[
NCPU
];
struct
runq
runqs
[
NCPU
];
struct
runq
runqs
[
NCPU
];
int
idle
[
NCPU
];
int
idle
[
NCPU
];
static
struct
proc
*
initproc
;
static
struct
proc
*
initproc
;
...
@@ -28,13 +27,7 @@ pinit(void)
...
@@ -28,13 +27,7 @@ pinit(void)
panic
(
"pinit"
);
panic
(
"pinit"
);
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
idle
[
c
]
=
1
;
idle
[
c
]
=
1
;
ptables
[
c
].
nextpid
=
(
c
<<
16
)
|
(
1
);
ptables
[
c
].
name
[
0
]
=
(
char
)
(
c
+
'0'
);
safestrcpy
(
ptables
[
c
].
name
+
1
,
"ptable"
,
MAXNAME
-
1
);
initlock
(
&
ptables
[
c
].
lock
,
ptables
[
c
].
name
);
runqs
[
c
].
name
[
0
]
=
(
char
)
(
c
+
'0'
);
runqs
[
c
].
name
[
0
]
=
(
char
)
(
c
+
'0'
);
safestrcpy
(
runqs
[
c
].
name
+
1
,
"runq"
,
MAXNAME
-
1
);
safestrcpy
(
runqs
[
c
].
name
+
1
,
"runq"
,
MAXNAME
-
1
);
initlock
(
&
runqs
[
c
].
lock
,
runqs
[
c
].
name
);
initlock
(
&
runqs
[
c
].
lock
,
runqs
[
c
].
name
);
...
@@ -61,7 +54,6 @@ allocproc(void)
...
@@ -61,7 +54,6 @@ allocproc(void)
initcondvar
(
&
p
->
cv
,
"proc"
);
initcondvar
(
&
p
->
cv
,
"proc"
);
p
->
state
=
EMBRYO
;
p
->
state
=
EMBRYO
;
// p->pid = ptable->nextpid++;
p
->
pid
=
ns_allockey
(
nspid
);
p
->
pid
=
ns_allockey
(
nspid
);
if
(
ns_insert
(
nspid
,
p
->
pid
,
(
void
*
)
p
)
<
0
)
if
(
ns_insert
(
nspid
,
p
->
pid
,
(
void
*
)
p
)
<
0
)
panic
(
"allocproc: ns_insert"
);
panic
(
"allocproc: ns_insert"
);
...
@@ -487,9 +479,7 @@ scheduler(void)
...
@@ -487,9 +479,7 @@ scheduler(void)
struct
proc
*
p
;
struct
proc
*
p
;
int
pid
;
int
pid
;
acquire
(
&
ptable
->
lock
);
pid
=
ns_allockey
(
nspid
);
pid
=
ptable
->
nextpid
++
;
release
(
&
ptable
->
lock
);
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpunum());
// mtrace_call_set(1, cpunum());
...
...
proc.h
浏览文件 @
cd61c6de
...
@@ -37,7 +37,6 @@ struct vmnode {
...
@@ -37,7 +37,6 @@ struct vmnode {
uint
npages
;
uint
npages
;
char
*
page
[
128
];
char
*
page
[
128
];
uint
ref
;
uint
ref
;
uint
alloc
;
// in use?
enum
vmntype
type
;
enum
vmntype
type
;
struct
inode
*
ip
;
struct
inode
*
ip
;
uint
offset
;
uint
offset
;
...
@@ -110,7 +109,6 @@ struct cpu {
...
@@ -110,7 +109,6 @@ struct cpu {
// Cpu-local storage variables; see below
// Cpu-local storage variables; see below
struct
cpu
*
cpu
;
struct
cpu
*
cpu
;
struct
proc
*
proc
;
// The currently-running process.
struct
proc
*
proc
;
// The currently-running process.
struct
ptable
*
ptable
;
// The per-core proc table
struct
kmem
*
kmem
;
// The per-core memory table
struct
kmem
*
kmem
;
// The per-core memory table
struct
runq
*
runq
;
// The per-core runq
struct
runq
*
runq
;
// The per-core runq
};
};
...
@@ -121,20 +119,12 @@ struct runq {
...
@@ -121,20 +119,12 @@ struct runq {
STAILQ_HEAD
(
runlist
,
proc
)
runq
;
STAILQ_HEAD
(
runlist
,
proc
)
runq
;
};
};
struct
ptable
{
char
name
[
MAXNAME
];
struct
spinlock
lock
;
struct
proc
*
runq
;
int
nextpid
;
};
struct
condtab
{
struct
condtab
{
char
name
[
MAXNAME
];
char
name
[
MAXNAME
];
struct
spinlock
lock
;
struct
spinlock
lock
;
struct
condvar
condtab
[
NPROC
];
struct
condvar
condtab
[
NPROC
];
};
};
extern
struct
ptable
ptables
[
NCPU
];
extern
struct
cpu
cpus
[
NCPU
];
extern
struct
cpu
cpus
[
NCPU
];
extern
struct
runq
runqs
[
NCPU
];
extern
struct
runq
runqs
[
NCPU
];
extern
struct
condtab
condtabs
[
NCPU
];
extern
struct
condtab
condtabs
[
NCPU
];
...
@@ -150,6 +140,5 @@ extern int ncpu;
...
@@ -150,6 +140,5 @@ extern int ncpu;
// in thread libraries such as Linux pthreads.
// in thread libraries such as Linux pthreads.
extern
struct
cpu
*
cpu
__asm
(
"%gs:0"
);
// &cpus[cpunum()]
extern
struct
cpu
*
cpu
__asm
(
"%gs:0"
);
// &cpus[cpunum()]
extern
struct
proc
*
proc
__asm
(
"%gs:4"
);
// cpus[cpunum()].proc
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:8"
);
// &kmems[cpunum()]
extern
struct
kmem
*
kmem
__asm
(
"%gs:12"
);
// &kmems[cpunum()]
extern
struct
runq
*
runq
__asm
(
"%gs:12"
);
// &runqs[cpunum()]
extern
struct
runq
*
runq
__asm
(
"%gs:16"
);
// &runqs[cpunum()]
vm.c
浏览文件 @
cd61c6de
...
@@ -31,8 +31,8 @@ seginit(void)
...
@@ -31,8 +31,8 @@ seginit(void)
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UCODE
]
=
SEG
(
STA_X
|
STA_R
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
DPL_USER
);
c
->
gdt
[
SEG_UDATA
]
=
SEG
(
STA_W
,
0
,
0xffffffff
,
DPL_USER
);
// Map cpu, curproc,
ptable,
kmem, runq
// Map cpu, curproc, kmem, runq
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
20
,
0
);
c
->
gdt
[
SEG_KCPU
]
=
SEG
(
STA_W
,
&
c
->
cpu
,
16
,
0
);
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
lgdt
(
c
->
gdt
,
sizeof
(
c
->
gdt
));
loadgs
(
SEG_KCPU
<<
3
);
loadgs
(
SEG_KCPU
<<
3
);
...
@@ -40,7 +40,6 @@ seginit(void)
...
@@ -40,7 +40,6 @@ seginit(void)
// Initialize cpu-local storage.
// Initialize cpu-local storage.
cpu
=
c
;
cpu
=
c
;
proc
=
0
;
proc
=
0
;
ptable
=
&
ptables
[
cpunum
()];
kmem
=
&
kmems
[
cpunum
()];
kmem
=
&
kmems
[
cpunum
()];
runq
=
&
runqs
[
cpunum
()];
runq
=
&
runqs
[
cpunum
()];
}
}
...
@@ -259,9 +258,9 @@ struct {
...
@@ -259,9 +258,9 @@ struct {
struct
vmnode
*
struct
vmnode
*
vmn_alloc
(
uint
npg
,
uint
type
)
vmn_alloc
(
uint
npg
,
uint
type
)
{
{
for
(
uint
i
=
0
;
i
<
NELEM
(
vmnodes
.
n
);
i
++
)
{
struct
vmnode
*
n
=
kmalloc
(
sizeof
(
struct
vmnode
));
struct
vmnode
*
n
=
&
vmnodes
.
n
[
i
];
if
(
n
==
0
)
if
(
n
->
alloc
==
0
&&
__sync_bool_compare_and_swap
(
&
n
->
alloc
,
0
,
1
))
{
panic
(
"out of vmnodes"
);
if
(
npg
>
NELEM
(
n
->
page
))
{
if
(
npg
>
NELEM
(
n
->
page
))
{
panic
(
"vmnode too big
\n
"
);
panic
(
"vmnode too big
\n
"
);
}
}
...
@@ -272,9 +271,6 @@ vmn_alloc(uint npg, uint type)
...
@@ -272,9 +271,6 @@ vmn_alloc(uint npg, uint type)
n
->
ip
=
0
;
n
->
ip
=
0
;
n
->
type
=
type
;
n
->
type
=
type
;
return
n
;
return
n
;
}
}
panic
(
"out of vmnodes"
);
}
}
static
int
static
int
...
@@ -311,7 +307,7 @@ vmn_free(struct vmnode *n)
...
@@ -311,7 +307,7 @@ vmn_free(struct vmnode *n)
if
(
n
->
ip
)
if
(
n
->
ip
)
iput
(
n
->
ip
);
iput
(
n
->
ip
);
n
->
ip
=
0
;
n
->
ip
=
0
;
n
->
alloc
=
0
;
kmfree
(
n
)
;
}
}
void
void
...
@@ -449,8 +445,7 @@ vmap_remove(struct vmap *m, uint va_start, uint len)
...
@@ -449,8 +445,7 @@ vmap_remove(struct vmap *m, uint va_start, uint len)
cprintf
(
"vmap_remove: partial unmap unsupported
\n
"
);
cprintf
(
"vmap_remove: partial unmap unsupported
\n
"
);
return
-
1
;
return
-
1
;
}
}
vmn_decref
(
m
->
e
[
i
].
n
);
__sync_fetch_and_sub
(
&
m
->
e
[
i
].
n
->
ref
,
1
);
// XXX shouldn't use vmn_decref?
m
->
e
[
i
].
n
=
0
;
m
->
e
[
i
].
n
=
0
;
}
}
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论