Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
89ae1d13
提交
89ae1d13
2月 11, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More pread, syscall crud
上级
47ab9b8c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
34 行增加
和
2 行删除
+34
-2
ipc.h
ipc.h
+4
-1
kernlet.c
kernlet.c
+3
-0
preadtest.cc
preadtest.cc
+27
-1
没有找到文件。
ipc.h
浏览文件 @
89ae1d13
struct
ipcctl
{
volatile
char
done
;
volatile
char
done
:
1
;
volatile
char
submitted
:
1
;
off_t
off
;
volatile
long
result
;
};
kernlet.c
浏览文件 @
89ae1d13
...
...
@@ -59,6 +59,7 @@ sys_kernlet(int fd, size_t count, off_t off)
{
struct
file
*
f
;
struct
work
*
w
;
struct
ipcctl
*
ipc
=
(
struct
ipcctl
*
)
myproc
()
->
vmap
->
kshared
;
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
myproc
()
->
ofile
[
fd
])
==
0
)
return
-
1
;
...
...
@@ -76,5 +77,7 @@ sys_kernlet(int fd, size_t count, off_t off)
freework
(
w
);
return
-
1
;
}
ipc
->
off
=
off
;
ipc
->
submitted
=
1
;
return
0
;
}
preadtest.cc
浏览文件 @
89ae1d13
...
...
@@ -2,6 +2,7 @@
#include "stat.h"
#include "fcntl.h"
#include "user.h"
#include "lib.h"
#include "amd64.h"
#include "ipc.h"
...
...
@@ -24,6 +25,31 @@ kernlet_pread(int fd, size_t count, off_t off)
die
(
"kernlet"
);
}
static
ssize_t
xpread
(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
off
)
{
if
(
ipcctl
->
submitted
)
{
while
(
ipcctl
->
done
==
0
)
nop_pause
();
if
(
ipcctl
->
result
==
-
1
)
goto
slow
;
if
(
off
<
ipcctl
->
off
)
goto
slow
;
if
(
off
>
ipcctl
->
off
+
ipcctl
->
result
)
goto
slow
;
char
*
kbuf
=
(
char
*
)
(
KSHARED
+
4096
);
off_t
kbufoff
=
off
-
ipcctl
->
off
;
size_t
kbufcount
=
MIN
(
count
,
ipcctl
->
result
-
kbufoff
);
memmove
(
buf
,
kbuf
+
kbufoff
,
kbufcount
);
return
kbufcount
;
}
slow:
return
pread
(
fd
,
buf
,
count
,
off
);
}
int
main
(
int
ac
,
char
**
av
)
{
...
...
@@ -44,7 +70,7 @@ main(int ac, char **av)
kernlet_pread
(
fd
,
PSIZE
,
k
);
for
(
i
=
k
;
i
<
k
+
PSIZE
;
i
+=
BSIZE
)
if
(
pread
(
fd
,
buf
,
BSIZE
,
i
)
!=
BSIZE
)
if
(
x
pread
(
fd
,
buf
,
BSIZE
,
i
)
!=
BSIZE
)
die
(
"pread failed"
);
}
t1
=
rdtsc
();
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论