Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
e38988a8
提交
e38988a8
4月 12, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
For userspace to explicitly enable user wqs
上级
dcddf43f
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
39 行增加
和
102 行删除
+39
-102
elf.hh
include/elf.hh
+0
-32
uwq.hh
include/uwq.hh
+2
-4
wquser.hh
include/wquser.hh
+1
-13
exec.cc
kernel/exec.cc
+0
-41
uwq.cc
kernel/uwq.cc
+21
-10
wquser.cc
lib/wquser.cc
+15
-2
没有找到文件。
include/elf.hh
浏览文件 @
e38988a8
...
...
@@ -54,35 +54,3 @@ struct elfnote {
#define ELF_PROG_FLAG_EXEC 1
#define ELF_PROG_FLAG_WRITE 2
#define ELF_PROG_FLAG_READ 4
// All known .note types
#define ELF_NOTE_XV6_ADDR 1
// xv6-specific address note
struct
xv6_addrdesc
{
Elf64_Word
id
;
Elf64_Addr
vaddr
;
};
struct
xv6_addrnote
{
struct
elfnote
elfnote
;
// name is 0 bytes
struct
xv6_addrdesc
desc
;
};
// All xv6-specific IDs for notes about addresses
#define XV6_ADDR_ID_WQ 1
#define DEFINE_XV6_ADDRNOTE(xname, xid, xvaddr) \
const struct xv6_addrnote xname PROG_NOTE_ATTRIBUTE = { \
elfnote: { \
namesz: 0, \
descsz: sizeof(((xv6_addrnote *)nullptr)->desc), \
type: ELF_NOTE_XV6_ADDR \
}, \
desc: { \
id: (xid), \
vaddr: (Elf64_Addr)(xvaddr) } \
}
#define PROG_NOTE_ATTRIBUTE __attribute__ ((section(".note"), used))
include/uwq.hh
浏览文件 @
e38988a8
...
...
@@ -35,19 +35,17 @@ struct uwq_worker {
struct
uwq
:
public
referenced
,
public
rcu_freed
{
friend
struct
uwq_worker
;
static
uwq
*
alloc
(
vmap
*
vmap
,
filetable
*
ftable
);
static
uwq
*
alloc
(
vmap
*
vmap
,
filetable
*
ftable
,
uptr
uentry
);
bool
haswork
()
const
;
bool
tryworker
();
void
setuentry
(
uptr
uentry
);
virtual
void
do_gc
(
void
)
{
delete
this
;
}
protected
:
virtual
void
onzero
()
const
;
private
:
uwq
(
vmap
*
vmap
,
filetable
*
ftable
,
uwq_ipcbuf
*
ipc
);
uwq
(
vmap
*
vmap
,
filetable
*
ftable
,
uwq_ipcbuf
*
ipc
,
uptr
uentry
);
~
uwq
();
uwq
&
operator
=
(
const
uwq
&
);
uwq
(
const
uwq
&
x
);
...
...
include/wquser.hh
浏览文件 @
e38988a8
...
...
@@ -2,11 +2,11 @@
#include "uspinlock.h"
#include "amd64.h"
#include "user.h"
#include "memlayout.h"
#include "uwq.hh"
#include "wqtypes.hh"
int
mycpuid
(
void
);
uwq_ipcbuf
*
allocipc
(
void
);
static
inline
void
*
allocwq
(
unsigned
long
nbytes
)
...
...
@@ -20,18 +20,6 @@ freewq(void* p)
free
(
p
);
}
static
inline
uwq_ipcbuf
*
allocipc
(
void
)
{
static
bool
alloced
;
if
(
alloced
)
die
(
"allocklen: allocing more than once"
);
if
(
sizeof
(
uwq_ipcbuf
)
>
USERWQSIZE
)
die
(
"allocipc: too large"
);
alloced
=
true
;
return
(
uwq_ipcbuf
*
)
USERWQ
;
}
static
inline
void
wqlock_acquire
(
wqlock_t
*
lock
)
{
...
...
kernel/exec.cc
浏览文件 @
e38988a8
...
...
@@ -19,36 +19,6 @@
#define BRK (USERTOP >> 1)
static
int
donotes
(
struct
inode
*
ip
,
uwq
*
uwq
,
u64
off
)
{
struct
proghdr
ph
;
struct
elfnote
note
;
if
(
readi
(
ip
,
(
char
*
)
&
ph
,
off
,
sizeof
(
ph
))
!=
sizeof
(
ph
))
return
-
1
;
if
(
readi
(
ip
,
(
char
*
)
&
note
,
ph
.
offset
,
sizeof
(
note
))
!=
sizeof
(
note
))
return
-
1
;
if
(
note
.
type
==
ELF_NOTE_XV6_ADDR
)
{
struct
xv6_addrdesc
desc
;
if
(
note
.
descsz
!=
sizeof
(
desc
))
return
-
1
;
if
(
readi
(
ip
,
(
char
*
)
&
desc
,
ph
.
offset
+
__offsetof
(
struct
xv6_addrnote
,
desc
),
sizeof
(
desc
))
!=
sizeof
(
desc
))
return
-
1
;
if
(
desc
.
id
==
XV6_ADDR_ID_WQ
)
{
uwq
->
setuentry
(
desc
.
vaddr
);
return
0
;
}
}
return
-
1
;
}
static
int
dosegment
(
inode
*
ip
,
vmap
*
vmp
,
u64
off
)
{
struct
proghdr
ph
;
...
...
@@ -177,7 +147,6 @@ exec(const char *path, char **argv, void *ascopev)
ANON_REGION
(
__func__
,
&
perfgroup
);
struct
inode
*
ip
=
nullptr
;
struct
vmap
*
vmp
=
nullptr
;
uwq
*
newuwq
=
nullptr
;
const
char
*
s
,
*
last
;
struct
elfhdr
elf
;
struct
proghdr
ph
;
...
...
@@ -218,9 +187,6 @@ exec(const char *path, char **argv, void *ascopev)
if
((
vmp
=
vmap
::
alloc
())
==
0
)
goto
bad
;
if
((
newuwq
=
uwq
::
alloc
(
vmp
,
myproc
()
->
ftable
))
==
0
)
goto
bad
;
for
(
i
=
0
,
off
=
elf
.
phoff
;
i
<
elf
.
phnum
;
i
++
,
off
+=
sizeof
(
ph
)){
Elf64_Word
type
;
if
(
readi
(
ip
,
(
char
*
)
&
type
,
...
...
@@ -229,10 +195,6 @@ exec(const char *path, char **argv, void *ascopev)
goto
bad
;
switch
(
type
)
{
case
ELF_PROG_NOTE
:
if
(
donotes
(
ip
,
newuwq
,
off
)
<
0
)
goto
bad
;
break
;
case
ELF_PROG_LOAD
:
if
(
dosegment
(
ip
,
vmp
,
off
)
<
0
)
goto
bad
;
...
...
@@ -254,7 +216,6 @@ exec(const char *path, char **argv, void *ascopev)
oldvmap
=
myproc
()
->
vmap
;
olduwq
=
myproc
()
->
uwq
;
myproc
()
->
vmap
=
vmp
;
myproc
()
->
uwq
=
newuwq
;
myproc
()
->
tf
->
rip
=
elf
.
entry
;
myproc
()
->
tf
->
rsp
=
sp
;
...
...
@@ -279,8 +240,6 @@ exec(const char *path, char **argv, void *ascopev)
cprintf
(
"exec failed
\n
"
);
if
(
vmp
)
vmp
->
decref
();
if
(
newuwq
)
newuwq
->
dec
();
gc_end_epoch
();
return
0
;
}
kernel/uwq.cc
浏览文件 @
e38988a8
...
...
@@ -54,6 +54,23 @@ uwq_trywork(void)
//SYSCALL
int
sys_wqinit
(
uptr
uentry
)
{
uwq
*
uwq
;
if
(
myproc
()
->
uwq
!=
nullptr
)
return
-
1
;
uwq
=
uwq
::
alloc
(
myproc
()
->
vmap
,
myproc
()
->
ftable
,
uentry
);
if
(
uwq
==
nullptr
)
return
-
1
;
myproc
()
->
uwq
=
uwq
;
return
0
;
}
//SYSCALL
int
sys_wqwait
(
void
)
{
uwq_worker
*
w
=
myproc
()
->
worker
;
...
...
@@ -103,7 +120,7 @@ uwq_worker::wait(void)
// uwq
//
uwq
*
uwq
::
alloc
(
vmap
*
vmap
,
filetable
*
ftable
)
uwq
::
alloc
(
vmap
*
vmap
,
filetable
*
ftable
,
uptr
uentry
)
{
uwq_ipcbuf
*
ipc
;
uwq
*
u
;
...
...
@@ -115,7 +132,7 @@ uwq::alloc(vmap* vmap, filetable *ftable)
ftable
->
incref
();
vmap
->
incref
();
u
=
new
uwq
(
vmap
,
ftable
,
ipc
);
u
=
new
uwq
(
vmap
,
ftable
,
ipc
,
uentry
);
if
(
u
==
nullptr
)
{
ftable
->
decref
();
vmap
->
decref
();
...
...
@@ -131,10 +148,10 @@ uwq::alloc(vmap* vmap, filetable *ftable)
return
u
;
}
uwq
::
uwq
(
vmap
*
vmap
,
filetable
*
ftable
,
uwq_ipcbuf
*
ipc
)
uwq
::
uwq
(
vmap
*
vmap
,
filetable
*
ftable
,
uwq_ipcbuf
*
ipc
,
uptr
uentry
)
:
rcu_freed
(
"uwq"
),
vmap_
(
vmap
),
ftable_
(
ftable
),
ipc_
(
ipc
),
uentry_
(
0
),
ustack_
(
UWQSTACK
),
uref_
(
0
)
uentry_
(
uentry
),
ustack_
(
UWQSTACK
),
uref_
(
0
)
{
for
(
int
i
=
0
;
i
<
NELEM
(
ipc_
->
len
);
i
++
)
ipc_
->
len
[
i
].
v_
=
0
;
...
...
@@ -254,12 +271,6 @@ uwq::onzero() const
u
->
finish
();
}
void
uwq
::
setuentry
(
uptr
uentry
)
{
uentry_
=
uentry
;
}
proc
*
uwq
::
allocworker
(
void
)
{
...
...
lib/wquser.cc
浏览文件 @
e38988a8
...
...
@@ -5,7 +5,7 @@
#include "wq.hh"
#include "atomic.hh"
#include "pthread.h"
#include "
elf.h
h"
#include "
memlayout.
h"
u64
wq_maxworkers
=
NWORKERS
;
...
...
@@ -28,7 +28,20 @@ initworker(void)
assert
(
wqwait
()
==
0
);
}
}
DEFINE_XV6_ADDRNOTE
(
xnote
,
XV6_ADDR_ID_WQ
,
&
initworker
);
uwq_ipcbuf
*
allocipc
(
void
)
{
static
bool
alloced
;
if
(
alloced
)
die
(
"allocklen: allocing more than once"
);
if
(
sizeof
(
uwq_ipcbuf
)
>
USERWQSIZE
)
die
(
"allocipc: too large"
);
if
(
wqinit
((
uptr
)
initworker
)
<
0
)
die
(
"wqinit: failed"
);
alloced
=
true
;
return
(
uwq_ipcbuf
*
)
USERWQ
;
}
int
mycpuid
(
void
)
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论