Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
451f323d
提交
451f323d
2月 18, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
System call hacking stuff
上级
8160fa28
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
44 行增加
和
8 行删除
+44
-8
preadtest.cc
preadtest.cc
+44
-8
没有找到文件。
preadtest.cc
浏览文件 @
451f323d
...
...
@@ -14,12 +14,20 @@
#define BSIZE 4096
#define PSIZE (4*BSIZE)
static
int
use
kernlet
;
static
int
use
_async
;
static
char
buf
[
BSIZE
];
struct
ipcctl
*
ipcctl
=
(
struct
ipcctl
*
)
KSHARED
;
struct
{
u64
acount
;
u64
atot
;
u64
pcount
;
u64
ptot
;
}
stats
;
static
msgid_t
ipc_msg_alloc
(
void
)
{
...
...
@@ -70,7 +78,12 @@ kernlet_pread(int fd, size_t count, off_t off)
struct
ipcmsg
*
msg
;
msgid_t
msgid
;
pageid_t
pageid
;
u64
t0
,
t1
;
if
(
!
use_async
)
return
;
t0
=
rdtsc
();
msgid
=
ipc_msg_alloc
();
if
(
msgid
==
NULL_MSGID
)
{
fprintf
(
2
,
"kernlet_pread: ipc_alloc_msg failed"
);
...
...
@@ -91,14 +104,20 @@ kernlet_pread(int fd, size_t count, off_t off)
if
(
async
(
fd
,
count
,
off
,
msgid
,
pageid
)
!=
0
)
die
(
"kernlet"
);
t1
=
rdtsc
();
stats
.
acount
++
;
stats
.
atot
+=
t1
-
t0
;
}
static
ssize_t
xpread
(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
off
)
{
struct
ipcmsg
*
msg
;
u64
t0
,
t1
;
int
msgid
;
t0
=
rdtsc
();
msgid
=
ipcctl
->
msgtail
%
IPC_NMSG
;
msg
=
&
ipcctl
->
msg
[
msgid
];
...
...
@@ -108,7 +127,7 @@ xpread(int fd, void *buf, size_t count, off_t off)
if
(
msg
->
result
==
-
1
)
die
(
"xpread: result oops"
);
if
(
msg
->
off
!=
off
)
die
(
"xpread: off oops
"
);
die
(
"xpread: off oops
%lu"
,
off
);
char
*
kbuf
=
(
char
*
)
(
KSHARED
+
PGSIZE
+
(
msg
->
pageid
*
PGSIZE
));
off_t
kbufoff
=
off
-
msg
->
off
;
...
...
@@ -117,10 +136,17 @@ xpread(int fd, void *buf, size_t count, off_t off)
memmove
(
buf
,
kbuf
+
kbufoff
,
kbufcount
);
ipc_msg_free
(
msgid
);
ipc_page_free
(
msg
->
pageid
);
t1
=
rdtsc
();
stats
.
pcount
++
;
stats
.
ptot
+=
t1
-
t0
;
return
kbufcount
;
}
return
pread
(
fd
,
buf
,
count
,
off
);
ssize_t
r
=
pread
(
fd
,
buf
,
count
,
off
);
t1
=
rdtsc
();
stats
.
pcount
++
;
stats
.
ptot
+=
t1
-
t0
;
return
r
;
}
int
...
...
@@ -133,7 +159,7 @@ main(int ac, char **av)
memset
(
ipcctl
,
0
,
sizeof
(
*
ipcctl
));
if
(
ac
>
1
)
use
kernlet
=
av
[
1
][
0
]
==
'k
'
;
use
_async
=
av
[
1
][
0
]
==
'a
'
;
fd
=
open
(
"preadtest.x"
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
)
...
...
@@ -144,16 +170,26 @@ main(int ac, char **av)
die
(
"write failed"
);
t0
=
rdtsc
();
kernlet_pread
(
fd
,
BSIZE
,
0
);
kernlet_pread
(
fd
,
BSIZE
,
0
*
BSIZE
);
kernlet_pread
(
fd
,
BSIZE
,
1
*
BSIZE
);
kernlet_pread
(
fd
,
BSIZE
,
2
*
BSIZE
);
kernlet_pread
(
fd
,
BSIZE
,
3
*
BSIZE
);
kernlet_pread
(
fd
,
BSIZE
,
4
*
BSIZE
);
for
(
i
=
0
;
i
<
FSIZE
;
i
+=
BSIZE
)
{
if
(
xpread
(
fd
,
buf
,
BSIZE
,
i
)
!=
BSIZE
)
die
(
"pread failed"
);
kernlet_pread
(
fd
,
BSIZE
,
i
+
BSIZE
);
if
(
i
+
BSIZE
+
3
*
BSIZE
<
FSIZE
)
kernlet_pread
(
fd
,
BSIZE
,
i
+
BSIZE
+
4
*
BSIZE
);
}
t1
=
rdtsc
();
fprintf
(
1
,
"usekernlet %u
\n
"
,
usekernlet
);
fprintf
(
1
,
"cycles %lu
\n
"
,
t1
-
t0
);
printf
(
"use_async %u
\n
"
,
use_async
);
printf
(
"pread: count %lu total %lu ave %lu
\n
"
,
stats
.
pcount
,
stats
.
ptot
,
stats
.
ptot
/
stats
.
pcount
);
if
(
use_async
)
printf
(
"async: count %lu total %lu ave %lu
\n
"
,
stats
.
acount
,
stats
.
atot
,
stats
.
atot
/
stats
.
acount
);
printf
(
"total %lu
\n
"
,
t1
-
t0
);
exit
();
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论