Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
7c537db5
提交
7c537db5
2月 09, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More pread/syscall stuff
上级
0f906e2c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
78 行增加
和
7 行删除
+78
-7
ipc.h
ipc.h
+4
-0
kernlet.c
kernlet.c
+67
-2
preadtest.c
preadtest.c
+7
-5
没有找到文件。
ipc.h
0 → 100644
浏览文件 @
7c537db5
struct
ipcctl
{
volatile
char
done
;
volatile
long
result
;
};
kernlet.c
浏览文件 @
7c537db5
#include "types.h"
#include "types.h"
#include "kernel.h"
#include "kernel.h"
#include "spinlock.h"
#include "condvar.h"
#include "cpu.h"
#include "proc.h"
#include "vm.h"
#include "fs.h"
#include "file.h"
#include "wq.h"
#include "ipc.h"
static
void
pread_work
(
struct
work
*
w
,
void
*
a0
,
void
*
a1
,
void
*
a2
,
void
*
a3
)
{
struct
inode
*
ip
=
a0
;
void
*
kshared
=
a1
;
struct
ipcctl
*
ipc
=
kshared
;
size_t
count
=
(
uptr
)
a2
;
off_t
off
=
(
uptr
)
a3
;
int
r
;
if
(
count
>
KSHAREDSIZE
-
PGSIZE
)
panic
(
"pread_work"
);
//cprintf("1: %p %p %lu %lu\n", ip, buf, count, off);
ilock
(
ip
,
0
);
r
=
readi
(
ip
,
kshared
+
PGSIZE
,
off
,
count
);
iunlock
(
ip
);
ipc
->
result
=
r
;
barrier
();
ipc
->
done
=
1
;
}
static
struct
work
*
pread_allocwork
(
struct
inode
*
ip
,
void
*
buf
,
size_t
count
,
off_t
off
)
{
struct
work
*
w
=
allocwork
();
if
(
w
==
NULL
)
return
NULL
;
//cprintf("0: %p %p %lu %lu\n", ip, buf, count, off);
w
->
rip
=
pread_work
;
w
->
arg0
=
ip
;
w
->
arg1
=
buf
;
w
->
arg2
=
(
void
*
)
count
;
w
->
arg3
=
(
void
*
)
off
;
return
w
;
}
long
long
sys_kernlet
(
int
fd
,
size_t
count
,
off_t
off
)
sys_kernlet
(
int
fd
,
size_t
count
,
off_t
off
)
{
{
struct
file
*
f
;
return
-
1
;
struct
work
*
w
;
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
myproc
()
->
ofile
[
fd
])
==
0
)
return
-
1
;
if
(
f
->
type
!=
FD_INODE
)
return
-
1
;
w
=
pread_allocwork
(
f
->
ip
,
myproc
()
->
vmap
->
kshared
,
count
,
off
);
if
(
w
==
NULL
)
return
-
1
;
if
(
wq_push
(
w
)
<
0
)
{
freework
(
w
);
return
-
1
;
}
return
0
;
}
}
preadtest.c
浏览文件 @
7c537db5
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "fcntl.h"
#include "fcntl.h"
#include "user.h"
#include "user.h"
#include "amd64.h"
#include "amd64.h"
#include "ipc.h"
// XXX(sbw) add a memlayout.h?
// XXX(sbw) add a memlayout.h?
#define KSHARED 0xFFFFF00000000000ull
#define KSHARED 0xFFFFF00000000000ull
...
@@ -13,11 +14,6 @@
...
@@ -13,11 +14,6 @@
static
char
buf
[
BSIZE
];
static
char
buf
[
BSIZE
];
struct
ipcctl
{
volatile
char
done
;
volatile
long
result
;
};
struct
ipcctl
*
ipcctl
=
(
struct
ipcctl
*
)
KSHARED
;
struct
ipcctl
*
ipcctl
=
(
struct
ipcctl
*
)
KSHARED
;
static
void
static
void
...
@@ -46,6 +42,12 @@ main(int ac, char **av)
...
@@ -46,6 +42,12 @@ main(int ac, char **av)
t0
=
rdtsc
();
t0
=
rdtsc
();
for
(
k
=
0
;
k
<
FSIZE
;
k
+=
PSIZE
)
{
for
(
k
=
0
;
k
<
FSIZE
;
k
+=
PSIZE
)
{
kernlet_pread
(
fd
,
PSIZE
,
k
);
kernlet_pread
(
fd
,
PSIZE
,
k
);
while
(
ipcctl
->
done
==
0
)
nop_pause
();
die
(
"preadtest: %d
\n
"
,
(
int
)
ipcctl
->
result
);
for
(
i
=
k
;
i
<
k
+
PSIZE
;
i
+=
BSIZE
)
for
(
i
=
k
;
i
<
k
+
PSIZE
;
i
+=
BSIZE
)
if
(
pread
(
fd
,
buf
,
BSIZE
,
i
)
!=
BSIZE
)
if
(
pread
(
fd
,
buf
,
BSIZE
,
i
)
!=
BSIZE
)
die
(
"pread failed"
);
die
(
"pread failed"
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论