Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9ef8078d
提交
9ef8078d
10月 23, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More ns.c and proc.c stuff.
上级
dc16e760
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
68 行增加
和
25 行删除
+68
-25
Makefile
Makefile
+1
-0
fs.c
fs.c
+12
-0
fs.h
fs.h
+5
-0
kernel.h
kernel.h
+15
-1
main.c
main.c
+2
-0
ns.c
ns.c
+13
-24
proc.c
proc.c
+20
-0
没有找到文件。
Makefile
浏览文件 @
9ef8078d
...
...
@@ -5,6 +5,7 @@ OBJS = \
cga.o
\
condvar.o
\
console.o
\
fs.o
\
lapic.o
\
kalloc.o
\
main.o
\
...
...
fs.c
浏览文件 @
9ef8078d
#include "types.h"
#include "kernel.h"
#include "fs.h"
int
namecmp
(
const
char
*
s
,
const
char
*
t
)
{
return
strncmp
(
s
,
t
,
DIRSIZ
);
}
#if 0
// File system implementation. Four layers:
// + Blocks: allocator for raw disk blocks.
// + Files: inode allocator, reading, writing, metadata.
...
...
@@ -764,3 +775,4 @@ nameiparent(char *path, char *name)
{
return namex(path, 1, name);
}
#endif
fs.h
浏览文件 @
9ef8078d
// Directory is a file containing a sequence of dirent structures.
#define DIRSIZ 14
#if 0
// On-disk file system format.
// Both the kernel and user programs use this header file.
...
...
@@ -51,3 +55,4 @@ struct dirent {
char name[DIRSIZ];
};
#endif
kernel.h
浏览文件 @
9ef8078d
...
...
@@ -25,6 +25,9 @@ void cv_wakeup(struct condvar *cv);
void
cprintf
(
const
char
*
,
...);
void
panic
(
const
char
*
)
__attribute__
((
noreturn
));
// fs.c
int
namecmp
(
const
char
*
,
const
char
*
);
// kalloc.c
char
*
kalloc
(
void
);
void
kfree
(
void
*
);
...
...
@@ -75,7 +78,7 @@ struct nskey {
void
nsinit
(
void
);
struct
ns
*
nsalloc
(
int
allowdup
);
void
nsfree
(
struct
ns
*
);
int
ns_allockey
(
struct
ns
*
);
u64
ns_allockey
(
struct
ns
*
);
int
ns_insert
(
struct
ns
*
,
struct
nskey
key
,
void
*
);
void
*
ns_lookup
(
struct
ns
*
,
struct
nskey
key
);
void
*
ns_remove
(
struct
ns
*
ns
,
struct
nskey
key
,
void
*
val
);
// removed val
...
...
@@ -98,6 +101,17 @@ int wait(void);
void
yield
(
void
);
void
migrate
(
struct
proc
*
);
// rcu.c
void
rcuinit
(
void
);
void
rcu_begin_write
(
struct
spinlock
*
);
void
rcu_end_write
(
struct
spinlock
*
);
void
rcu_begin_read
(
void
);
void
rcu_end_read
(
void
);
void
rcu_delayed
(
void
*
,
void
(
*
dofree
)(
void
*
));
void
rcu_delayed2
(
int
,
u64
,
void
(
*
dofree
)(
int
,
u64
));
void
rcu_gc
(
void
);
void
rcu_gc_worker
(
void
);
// spinlock.c
void
acquire
(
struct
spinlock
*
);
void
getcallerpcs
(
void
*
,
uptr
*
);
...
...
main.c
浏览文件 @
9ef8078d
...
...
@@ -12,6 +12,7 @@ extern void initseg(void);
extern
void
inittrap
(
void
);
extern
void
initkalloc
(
void
);
extern
void
initrcu
(
void
);
extern
void
initproc
(
void
);
void
cmain
(
void
)
...
...
@@ -28,6 +29,7 @@ cmain(void)
initkalloc
();
initrcu
();
// initialize rcu module
initproc
();
cprintf
(
"ncpu %d
\n
"
,
ncpu
);
panic
(
"end"
);
...
...
ns.c
浏览文件 @
9ef8078d
#include "types.h"
#include "kernel.h"
void
*
ns_enumerate
(
struct
ns
*
ns
,
void
*
(
*
f
)(
void
*
,
void
*
,
void
*
),
void
*
arg
)
{
panic
(
"ns_enumerate"
);
}
#if 0
#include "types.h"
#include "defs.h"
#include "spinlock.h"
#include "param.h"
#include "fs.h"
...
...
@@ -29,16 +19,16 @@ struct elem {
int
next_lock
;
struct
elem
*
volatile
next
;
union
{
u
int
ikey
;
u
64
ikey
;
struct
{
u
int
a
;
u
int
b
;
u
64
a
;
u
64
b
;
}
iikey
;
char
skey
[
0
];
char
dnkey
[
DIRSIZ
];
struct
{
u
int
a
;
u
int
b
;
u
64
a
;
u
64
b
;
char
s
[
0
];
}
iiskey
;
};
...
...
@@ -50,7 +40,7 @@ struct bucket {
struct
ns
{
int
allowdup
;
u
int
nextkey
;
u
64
nextkey
;
struct
bucket
table
[
NHASH
];
};
...
...
@@ -120,7 +110,7 @@ elemalloc(struct nskey *k)
return
e
;
}
static
int
static
u64
h
(
struct
nskey
*
k
)
{
switch
(
k
->
type
)
{
...
...
@@ -188,10 +178,10 @@ cmpkey(struct elem *e, struct nskey *k)
}
// XXX need something more scalable; partition the name space?
int
u64
ns_allockey
(
struct
ns
*
ns
)
{
u
int
n
=
__sync_fetch_and_add
(
&
ns
->
nextkey
,
1
);
u
64
n
=
__sync_fetch_and_add
(
&
ns
->
nextkey
,
1
);
return
n
;
}
...
...
@@ -202,7 +192,7 @@ ns_insert(struct ns *ns, struct nskey key, void *val)
if
(
e
)
{
setkey
(
e
,
&
key
);
e
->
val
=
val
;
u
int
i
=
h
(
&
key
);
u
64
i
=
h
(
&
key
);
rcu_begin_write
(
0
);
retry:
...
...
@@ -231,7 +221,7 @@ ns_insert(struct ns *ns, struct nskey key, void *val)
void
*
ns_lookup
(
struct
ns
*
ns
,
struct
nskey
key
)
{
u
int
i
=
h
(
&
key
);
u
64
i
=
h
(
&
key
);
rcu_begin_read
();
struct
elem
*
e
=
ns
->
table
[
i
].
chain
;
...
...
@@ -251,7 +241,7 @@ ns_lookup(struct ns *ns, struct nskey key)
void
*
ns_remove
(
struct
ns
*
ns
,
struct
nskey
key
,
void
*
v
)
{
u
int
i
=
h
(
&
key
);
u
64
i
=
h
(
&
key
);
rcu_begin_write
(
0
);
retry:
...
...
@@ -315,7 +305,7 @@ ns_enumerate(struct ns *ns, void *(*f)(void *, void *, void *), void *arg)
void
*
ns_enumerate_key
(
struct
ns
*
ns
,
struct
nskey
key
,
void
*
(
*
f
)(
void
*
,
void
*
),
void
*
arg
)
{
u
int
i
=
h
(
&
key
);
u
64
i
=
h
(
&
key
);
rcu_begin_read
();
struct
elem
*
e
=
ns
->
table
[
i
].
chain
;
while
(
e
)
{
...
...
@@ -331,4 +321,3 @@ ns_enumerate_key(struct ns *ns, struct nskey key, void *(*f)(void *, void *), vo
rcu_end_read
();
return
0
;
}
#endif
proc.c
浏览文件 @
9ef8078d
...
...
@@ -25,6 +25,26 @@ addrun(struct proc *p)
panic
(
"addrun"
);
}
void
initproc
(
void
)
{
int
c
;
nspid
=
nsalloc
(
0
);
if
(
nspid
==
0
)
panic
(
"pinit"
);
nsrunq
=
nsalloc
(
1
);
if
(
nsrunq
==
0
)
panic
(
"pinit runq"
);
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
idle
[
c
]
=
1
;
}
#if 0
extern void forkret(void);
extern void trapret(void);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论