Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
bfea5822
提交
bfea5822
2月 10, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
c++ userspace, half-way
上级
e899cb3b
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
76 行增加
和
37 行删除
+76
-37
cat.cc
cat.cc
+2
-0
dirbench.cc
dirbench.cc
+2
-0
echo.cc
echo.cc
+2
-0
forkexecbench.cc
forkexecbench.cc
+3
-1
forkexectree.cc
forkexectree.cc
+3
-1
forktree.cc
forktree.cc
+2
-0
halt.cc
halt.cc
+2
-0
httpd.cc
httpd.cc
+4
-2
init.cc
init.cc
+6
-4
kill.cc
kill.cc
+2
-0
lockstat.cc
lockstat.cc
+3
-1
mapbench.cc
mapbench.cc
+3
-1
net.mk
net.mk
+2
-1
rm.cc
rm.cc
+2
-0
sh.cc
sh.cc
+11
-9
sleep.cc
sleep.cc
+2
-0
telnetd.cc
telnetd.cc
+3
-1
thrtest.cc
thrtest.cc
+3
-1
time.cc
time.cc
+3
-1
user.h
user.h
+6
-6
usertests.cc
usertests.cc
+10
-8
没有找到文件。
cat.c
→
cat.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
}
char
buf
[
512
];
...
...
dirbench.c
→
dirbench.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
#include "amd64.h"
#include "fcntl.h"
}
enum
{
nthread
=
2
};
enum
{
nloop
=
100
};
...
...
echo.c
→
echo.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
forkexecbench.c
→
forkexecbench.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
#include "amd64.h"
}
#define NITERS 16
...
...
@@ -18,7 +20,7 @@ execbench(void)
exit
();
}
if
(
pid
==
0
)
{
char
*
av
[]
=
{
"forkexecbench"
,
"x"
,
0
};
c
onst
c
har
*
av
[]
=
{
"forkexecbench"
,
"x"
,
0
};
exec
(
"forkexecbench"
,
av
);
printf
(
1
,
"exec failed
\n
"
);
exit
();
...
...
forkexectree.c
→
forkexectree.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
}
#define NCHILD 2
#define NDEPTH 7
...
...
@@ -28,7 +30,7 @@ forktree(int depth)
depth
++
;
char
depthbuf
[
16
];
snprintf
(
depthbuf
,
sizeof
(
depthbuf
),
"%d"
,
depth
);
char
*
av
[]
=
{
"forkexectree"
,
depthbuf
};
c
onst
c
har
*
av
[]
=
{
"forkexectree"
,
depthbuf
};
exec
(
"forkexectree"
,
av
);
}
}
...
...
forktree.c
→
forktree.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
}
#define NCHILD 2
#define NDEPTH 5
...
...
halt.c
→
halt.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "user.h"
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
httpd.c
→
httpd.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "user.h"
#include "lib.h"
#include "unet.h"
#include "fcntl.h"
#include "stat.h"
}
#define VERSION "0.1"
#define HTTP_VERSION "1.0"
...
...
@@ -19,7 +21,7 @@ static int xwrite(int fd, const void *buf, u64 n)
printf
(
1
,
"xwrite: failed %d
\n
"
,
r
);
return
-
1
;
}
buf
+=
r
;
buf
=
(
char
*
)
buf
+
r
;
n
-=
r
;
}
...
...
@@ -208,7 +210,7 @@ parse(const char *b, char **rurl)
b
++
;
len
=
b
-
url
;
r
=
malloc
(
len
+
1
);
r
=
(
char
*
)
malloc
(
len
+
1
);
if
(
r
==
NULL
)
return
-
1
;
memmove
(
r
,
url
,
len
);
...
...
init.c
→
init.c
c
浏览文件 @
bfea5822
// init: The initial user-level program
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
#include "lib.h"
}
static
char
*
sh_argv
[]
=
{
"sh"
,
0
};
static
char
*
app_argv
[][
MAXARG
]
=
{
static
c
onst
c
har
*
sh_argv
[]
=
{
"sh"
,
0
};
static
c
onst
c
har
*
app_argv
[][
MAXARG
]
=
{
#ifdef LWIP
{
"telnetd"
,
0
},
{
"httpd"
,
0
},
...
...
@@ -15,7 +17,7 @@ static char *app_argv[][MAXARG] = {
};
static
int
startone
(
char
**
argv
)
startone
(
c
onst
c
har
**
argv
)
{
int
pid
;
...
...
@@ -52,7 +54,7 @@ main(void)
if
(
mknod
(
"/dev/lockstat"
,
4
,
1
)
<
0
)
printf
(
2
,
"init: mknod lockstat failed
\n
"
);
for
(
int
i
=
0
;
i
<
NELEM
(
app_argv
);
i
++
)
for
(
u32
i
=
0
;
i
<
NELEM
(
app_argv
);
i
++
)
startone
(
app_argv
[
i
]);
for
(;;){
...
...
kill.c
→
kill.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
}
int
main
(
int
argc
,
char
**
argv
)
...
...
lockstat.c
→
lockstat.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
#include "amd64.h"
#include "lockstat.h"
}
static
void
xwrite
(
int
fd
,
char
c
)
...
...
@@ -50,7 +52,7 @@ stats(void)
}
int
main
(
int
ac
,
char
*
av
[])
main
(
int
ac
,
c
onst
c
har
*
av
[])
{
int
fd
=
open
(
"/dev/lockstat"
,
O_RDWR
);
if
(
fd
<
0
)
...
...
mapbench.c
→
mapbench.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
#include "amd64.h"
#include "uspinlock.h"
}
static
struct
uspinlock
l
;
static
volatile
int
tcount
;
...
...
@@ -57,7 +59,7 @@ main(int ac, char **av)
sbrk
(
8192
);
void
*
tstack
=
sbrk
(
0
);
// printf(1, "tstack %lx\n", tstack);
int
tid
=
forkt
(
tstack
,
thr
,
(
void
*
)(
u64
)
i
);
int
tid
=
forkt
(
tstack
,
(
void
*
)
thr
,
(
void
*
)(
u64
)
i
);
if
(
0
)
printf
(
1
,
"mapbench[%d]: child %d
\n
"
,
getpid
(),
tid
);
}
...
...
net.mk
浏览文件 @
bfea5822
...
...
@@ -13,7 +13,8 @@ UPROGS += \
$(O)/_telnetd \
$(O)/_httpd
CFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
CFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
CXXFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
LWIP_CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb \
-m64 -Werror -std=c99 -fms-extensions -mno-sse -mcmodel=large -I$(QEMUSRC) \
...
...
rm.c
→
rm.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
sh.c
→
sh.c
c
浏览文件 @
bfea5822
// Shell.
extern
"C"
{
#include "types.h"
#include "user.h"
#include "fcntl.h"
}
// Parsed command representation
#define EXEC 1
...
...
@@ -19,7 +21,7 @@ struct cmd {
struct
execcmd
{
int
type
;
char
*
argv
[
MAXARGS
];
c
onst
c
har
*
argv
[
MAXARGS
];
char
*
eargv
[
MAXARGS
];
};
...
...
@@ -50,7 +52,7 @@ struct backcmd {
};
int
fork1
(
void
);
// Fork but panics on failure.
void
panic
(
char
*
);
void
panic
(
c
onst
c
har
*
);
struct
cmd
*
parsecmd
(
char
*
);
// Execute cmd. Never returns.
...
...
@@ -173,7 +175,7 @@ main(void)
}
void
panic
(
char
*
s
)
panic
(
c
onst
c
har
*
s
)
{
printf
(
2
,
"%s
\n
"
,
s
);
exit
();
...
...
@@ -198,7 +200,7 @@ execcmd(void)
{
struct
execcmd
*
cmd
;
cmd
=
malloc
(
sizeof
(
*
cmd
));
cmd
=
(
struct
execcmd
*
)
malloc
(
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
cmd
->
type
=
EXEC
;
return
(
struct
cmd
*
)
cmd
;
...
...
@@ -209,7 +211,7 @@ redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
struct
redircmd
*
cmd
;
cmd
=
malloc
(
sizeof
(
*
cmd
));
cmd
=
(
struct
redircmd
*
)
malloc
(
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
cmd
->
type
=
REDIR
;
cmd
->
cmd
=
subcmd
;
...
...
@@ -225,7 +227,7 @@ pipecmd(struct cmd *left, struct cmd *right)
{
struct
pipecmd
*
cmd
;
cmd
=
malloc
(
sizeof
(
*
cmd
));
cmd
=
(
struct
pipecmd
*
)
malloc
(
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
cmd
->
type
=
PIPE
;
cmd
->
left
=
left
;
...
...
@@ -238,7 +240,7 @@ listcmd(struct cmd *left, struct cmd *right)
{
struct
listcmd
*
cmd
;
cmd
=
malloc
(
sizeof
(
*
cmd
));
cmd
=
(
struct
listcmd
*
)
malloc
(
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
cmd
->
type
=
LIST
;
cmd
->
left
=
left
;
...
...
@@ -251,7 +253,7 @@ backcmd(struct cmd *subcmd)
{
struct
backcmd
*
cmd
;
cmd
=
malloc
(
sizeof
(
*
cmd
));
cmd
=
(
struct
backcmd
*
)
malloc
(
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
cmd
->
type
=
BACK
;
cmd
->
cmd
=
subcmd
;
...
...
@@ -309,7 +311,7 @@ gettoken(char **ps, char *es, char **q, char **eq)
}
int
peek
(
char
**
ps
,
char
*
es
,
char
*
toks
)
peek
(
char
**
ps
,
char
*
es
,
c
onst
c
har
*
toks
)
{
char
*
s
;
...
...
sleep.c
→
sleep.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
#include "amd64.h"
}
int
main
(
int
ac
,
char
*
av
[])
...
...
telnetd.c
→
telnetd.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "user.h"
#include "unet.h"
}
int
main
(
void
)
...
...
@@ -46,7 +48,7 @@ main(void)
continue
;
}
if
(
pid
==
0
)
{
static
char
*
argv
[]
=
{
"sh"
,
0
};
static
c
onst
c
har
*
argv
[]
=
{
"sh"
,
0
};
close
(
0
);
close
(
1
);
close
(
2
);
...
...
thrtest.c
→
thrtest.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "mtrace.h"
#include "amd64.h"
#include "uspinlock.h"
}
static
struct
uspinlock
l
;
static
volatile
int
tcount
;
...
...
@@ -28,7 +30,7 @@ main(void)
for
(
int
i
=
0
;
i
<
nthread
;
i
++
)
{
sbrk
(
8192
);
void
*
tstack
=
sbrk
(
0
);
int
tid
=
forkt
(
tstack
,
thr
,
(
void
*
)(
u64
)(
0xc0ffee00
|
i
));
int
tid
=
forkt
(
tstack
,
(
void
*
)
thr
,
(
void
*
)(
u64
)(
0xc0ffee00
|
i
));
printf
(
1
,
"thrtest[%d]: child %d
\n
"
,
getpid
(),
tid
);
}
...
...
time.c
→
time.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
#include "amd64.h"
}
int
main
(
int
ac
,
char
*
av
[])
main
(
int
ac
,
c
onst
c
har
*
av
[])
{
u64
t0
=
rdtsc
();
...
...
user.h
浏览文件 @
bfea5822
...
...
@@ -9,14 +9,14 @@ int write(int, const void*, int);
int
read
(
int
,
void
*
,
int
);
int
close
(
int
);
int
kill
(
int
);
int
exec
(
c
har
*
,
char
**
);
int
exec
(
c
onst
char
*
,
const
char
**
);
int
open
(
const
char
*
,
int
);
int
mknod
(
char
*
,
short
,
short
);
int
unlink
(
char
*
);
int
mknod
(
c
onst
c
har
*
,
short
,
short
);
int
unlink
(
c
onst
c
har
*
);
int
fstat
(
int
fd
,
struct
stat
*
);
int
link
(
c
har
*
,
char
*
);
int
mkdir
(
char
*
);
int
chdir
(
char
*
);
int
link
(
c
onst
char
*
,
const
char
*
);
int
mkdir
(
c
onst
c
har
*
);
int
chdir
(
c
onst
c
har
*
);
int
dup
(
int
);
int
getpid
(
void
);
char
*
sbrk
(
int
);
...
...
usertests.c
→
usertests.c
c
浏览文件 @
bfea5822
extern
"C"
{
#include "types.h"
#include "stat.h"
#include "user.h"
...
...
@@ -5,10 +6,11 @@
#include "fcntl.h"
#include "syscall.h"
#include "traps.h"
}
char
buf
[
2048
];
char
name
[
3
];
char
*
echoargv
[]
=
{
"echo"
,
"ALL"
,
"TESTS"
,
"PASSED"
,
0
};
c
onst
c
har
*
echoargv
[]
=
{
"echo"
,
"ALL"
,
"TESTS"
,
"PASSED"
,
0
};
int
stdout
=
1
;
// simple file system tests
...
...
@@ -85,7 +87,7 @@ writetest(void)
void
writetest1
(
void
)
{
int
i
,
fd
,
n
;
int
fd
,
n
;
printf
(
stdout
,
"big files test
\n
"
);
...
...
@@ -95,7 +97,7 @@ writetest1(void)
exit
();
}
for
(
i
=
0
;
i
<
MAXFILE
;
i
++
){
for
(
u32
i
=
0
;
i
<
MAXFILE
;
i
++
){
((
int
*
)
buf
)[
0
]
=
i
;
if
(
write
(
fd
,
buf
,
512
)
!=
512
){
printf
(
stdout
,
"error: write big file failed
\n
"
,
i
);
...
...
@@ -113,7 +115,7 @@ writetest1(void)
n
=
0
;
for
(;;){
i
=
read
(
fd
,
buf
,
512
);
u32
i
=
read
(
fd
,
buf
,
512
);
if
(
i
==
0
){
if
(
n
==
MAXFILE
-
1
){
printf
(
stdout
,
"read only %d blocks from big"
,
n
);
...
...
@@ -331,7 +333,7 @@ mem(void)
if
((
pid
=
fork
(
0
))
==
0
){
m1
=
0
;
while
((
m2
=
malloc
(
10001
))
!=
0
){
*
(
char
**
)
m2
=
m1
;
*
(
char
**
)
m2
=
(
char
*
)
m1
;
m1
=
m2
;
}
while
(
m1
){
...
...
@@ -410,7 +412,7 @@ void
twofiles
(
void
)
{
int
fd
,
pid
,
i
,
j
,
n
,
total
;
char
*
fname
;
c
onst
c
har
*
fname
;
printf
(
1
,
"twofiles test
\n
"
);
...
...
@@ -1450,7 +1452,7 @@ bigargtest(void)
pid
=
fork
(
0
);
if
(
pid
==
0
){
char
*
args
[
32
+
1
];
c
onst
c
har
*
args
[
32
+
1
];
int
i
;
for
(
i
=
0
;
i
<
32
;
i
++
)
args
[
i
]
=
"bigargs test: failed
\n
"
;
...
...
@@ -1467,7 +1469,7 @@ bigargtest(void)
}
void
uox
(
char
*
name
,
char
*
data
)
uox
(
char
*
name
,
c
onst
c
har
*
data
)
{
int
fd
=
open
(
name
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论