Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
78489020
提交
78489020
3月 31, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
forframe -> wframe
上级
8f88035a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
20 行增加
和
21 行删除
+20
-21
wqtest.cc
bin/wqtest.cc
+9
-9
wq.hh
include/wq.hh
+8
-0
wqfor.hh
include/wqfor.hh
+3
-12
没有找到文件。
bin/wqtest.cc
浏览文件 @
78489020
...
...
@@ -15,7 +15,7 @@
}
struct
testwork
:
public
work
{
testwork
(
for
frame
*
b
)
:
barrier_
(
b
)
{}
testwork
(
w
frame
*
b
)
:
barrier_
(
b
)
{}
virtual
void
run
()
{
barrier_
->
dec
();
...
...
@@ -23,14 +23,14 @@ struct testwork : public work {
}
NEW_DELETE_OPS
(
testwork
);
struct
for
frame
*
barrier_
;
struct
w
frame
*
barrier_
;
};
static
void
test0
(
void
)
{
enum
{
pushes
=
100
};
struct
for
frame
wqbarrier
(
pushes
);
struct
w
frame
wqbarrier
(
pushes
);
printf
(
"test0...
\n
"
);
for
(
int
i
=
0
;
i
<
pushes
;
i
++
)
{
...
...
@@ -44,7 +44,7 @@ test0(void)
}
struct
forkwork
:
public
work
{
forkwork
(
for
frame
*
b
)
:
barrier_
(
b
)
{}
forkwork
(
w
frame
*
b
)
:
barrier_
(
b
)
{}
virtual
void
run
()
{
int
pid
;
...
...
@@ -61,14 +61,14 @@ struct forkwork : public work {
}
NEW_DELETE_OPS
(
forkwork
);
struct
for
frame
*
barrier_
;
struct
w
frame
*
barrier_
;
};
static
void
testfork
(
void
)
{
enum
{
forks
=
100
};
struct
for
frame
wqbarrier
(
forks
);
struct
w
frame
wqbarrier
(
forks
);
printf
(
"testfork...
\n
"
);
for
(
int
i
=
0
;
i
<
forks
;
i
++
)
{
...
...
@@ -82,7 +82,7 @@ testfork(void)
}
struct
execwork
:
public
work
{
execwork
(
for
frame
*
b
)
:
barrier_
(
b
)
{}
execwork
(
w
frame
*
b
)
:
barrier_
(
b
)
{}
virtual
void
run
()
{
int
pid
;
...
...
@@ -103,7 +103,7 @@ struct execwork : public work {
static
void
test
(
void
)
{
enum
{
execs
=
100
};
struct
for
frame
wqbarrier
(
execs
);
struct
w
frame
wqbarrier
(
execs
);
printf
(
"testexec...
\n
"
);
for
(
int
i
=
0
;
i
<
execs
;
i
++
)
{
...
...
@@ -117,7 +117,7 @@ struct execwork : public work {
}
NEW_DELETE_OPS
(
execwork
);
struct
for
frame
*
barrier_
;
struct
w
frame
*
barrier_
;
};
int
...
...
include/wq.hh
浏览文件 @
78489020
...
...
@@ -29,6 +29,14 @@ struct cwork : public work {
void
*
arg4
;
};
struct
wframe
{
wframe
(
int
v
)
:
v_
(
v
)
{}
int
inc
()
{
return
__sync_add_and_fetch
(
&
v_
,
1
);
}
int
dec
()
{
return
__sync_sub_and_fetch
(
&
v_
,
1
);
}
bool
zero
()
volatile
{
return
v_
==
0
;
};
volatile
int
v_
;
};
#if defined(LINUX)
#include <stdlib.h>
#include <assert.h>
...
...
include/wqfor.hh
浏览文件 @
78489020
struct
forframe
{
forframe
(
int
v
)
:
v_
(
v
)
{}
int
inc
()
{
return
__sync_add_and_fetch
(
&
v_
,
1
);
}
int
dec
()
{
return
__sync_sub_and_fetch
(
&
v_
,
1
);
}
bool
zero
()
volatile
{
return
v_
==
0
;
};
volatile
int
v_
;
};
template
<
typename
IT
,
typename
BODY
>
struct
forwork
:
public
work
{
forwork
(
IT
&
it
,
bool
(
*
cond
)(
IT
&
it
),
BODY
&
body
,
for
frame
&
frame
)
forwork
(
IT
&
it
,
bool
(
*
cond
)(
IT
&
it
),
BODY
&
body
,
w
frame
&
frame
)
:
it_
(
it
),
cond_
(
cond
),
body_
(
body
),
frame_
(
frame
)
{}
virtual
void
run
()
{
...
...
@@ -38,14 +29,14 @@ struct forwork : public work {
IT
&
it_
;
bool
(
*
cond_
)(
IT
&
);
BODY
&
body_
;
for
frame
&
frame_
;
w
frame
&
frame_
;
};
template
<
typename
IT
,
typename
BODY
>
static
inline
void
wq_for
(
IT
&
init
,
bool
(
*
cond
)(
IT
&
it
),
BODY
body
)
{
for
frame
frame
(
0
);
w
frame
frame
(
0
);
// XXX(sbw) should be able to coarsen loop
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论