Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
2eb42789
提交
2eb42789
2月 19, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get rid of macros around gcc __sync_* ops
上级
8e76d1ae
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
16 行增加
和
19 行删除
+16
-19
cilk.cc
cilk.cc
+13
-13
lib.h
lib.h
+0
-4
proc.hh
proc.hh
+2
-1
qlock.h
qlock.h
+1
-1
没有找到文件。
cilk.cc
浏览文件 @
2eb42789
...
@@ -27,14 +27,14 @@
...
@@ -27,14 +27,14 @@
#if CILKENABLE
#if CILKENABLE
#include "types.h"
#include "types.h"
#include "kernel.h"
#include "kernel.h
h
"
#include "amd64.h"
#include "amd64.h"
#include "cpu.h"
#include "cpu.h
h
"
#include "bits.h"
#include "bits.h
h
"
#include "spinlock.h"
#include "spinlock.h"
#include "condvar.h"
#include "condvar.h"
#include "queue.h"
#include "queue.h"
#include "proc.h"
#include "proc.h
h
"
#include "mtrace.h"
#include "mtrace.h"
#include "qlock.h"
#include "qlock.h"
...
@@ -114,7 +114,7 @@ __cilk_pop(struct cilkqueue *q)
...
@@ -114,7 +114,7 @@ __cilk_pop(struct cilkqueue *q)
i
=
q
->
head
;
i
=
q
->
head
;
if
((
i
-
q
->
tail
)
==
0
)
{
if
((
i
-
q
->
tail
)
==
0
)
{
ql_unlock
(
&
q
->
lock
,
&
qn
);
ql_unlock
(
&
q
->
lock
,
&
qn
);
return
NULL
;
return
0
;
}
}
i
=
(
i
-
1
)
&
(
NSLOTS
-
1
);
i
=
(
i
-
1
)
&
(
NSLOTS
-
1
);
q
->
head
--
;
q
->
head
--
;
...
@@ -134,7 +134,7 @@ __cilk_steal(struct cilkqueue *q)
...
@@ -134,7 +134,7 @@ __cilk_steal(struct cilkqueue *q)
i
=
q
->
tail
;
i
=
q
->
tail
;
if
((
i
-
q
->
head
)
==
0
)
{
if
((
i
-
q
->
head
)
==
0
)
{
ql_unlock
(
&
q
->
lock
,
&
qn
);
ql_unlock
(
&
q
->
lock
,
&
qn
);
return
NULL
;
return
0
;
}
}
i
=
i
&
(
NSLOTS
-
1
);
i
=
i
&
(
NSLOTS
-
1
);
q
->
tail
++
;
q
->
tail
++
;
...
@@ -147,13 +147,13 @@ __cilk_steal(struct cilkqueue *q)
...
@@ -147,13 +147,13 @@ __cilk_steal(struct cilkqueue *q)
static
void
static
void
__cilk_run
(
struct
cilkthread
*
th
)
__cilk_run
(
struct
cilkthread
*
th
)
{
{
void
(
*
fn
)(
uptr
arg0
,
uptr
arg1
)
=
(
void
*
)
th
->
rip
;
void
(
*
fn
)(
uptr
arg0
,
uptr
arg1
)
=
(
void
(
*
)(
uptr
,
uptr
)
)
th
->
rip
;
struct
cilkframe
*
old
=
mycpu
()
->
cilkframe
;
struct
cilkframe
*
old
=
mycpu
()
->
cilkframe
;
mycpu
()
->
cilkframe
=
th
->
frame
;
mycpu
()
->
cilkframe
=
th
->
frame
;
fn
(
th
->
arg0
,
th
->
arg1
);
fn
(
th
->
arg0
,
th
->
arg1
);
mycpu
()
->
cilkframe
=
old
;
mycpu
()
->
cilkframe
=
old
;
subfetch
(
&
th
->
frame
->
ref
,
1
)
;
th
->
frame
->
ref
--
;
kfree
(
th
);
kfree
(
th
);
}
}
...
@@ -163,7 +163,7 @@ __cilk_run(struct cilkthread *th)
...
@@ -163,7 +163,7 @@ __cilk_run(struct cilkthread *th)
void
void
cilk_push
(
void
*
rip
,
u64
arg0
,
u64
arg1
)
cilk_push
(
void
*
rip
,
u64
arg0
,
u64
arg1
)
{
{
void
(
*
fn
)(
uptr
,
uptr
)
=
rip
;
void
(
*
fn
)(
uptr
,
uptr
)
=
(
void
(
*
)(
uptr
,
uptr
))
rip
;
struct
cilkthread
*
th
;
struct
cilkthread
*
th
;
th
=
(
struct
cilkthread
*
)
kalloc
();
th
=
(
struct
cilkthread
*
)
kalloc
();
...
@@ -179,8 +179,8 @@ cilk_push(void *rip, u64 arg0, u64 arg1)
...
@@ -179,8 +179,8 @@ cilk_push(void *rip, u64 arg0, u64 arg1)
if
(
__cilk_push
(
cilk_cur
(),
th
))
{
if
(
__cilk_push
(
cilk_cur
(),
th
))
{
kfree
(
th
);
kfree
(
th
);
fn
(
arg0
,
arg1
);
fn
(
arg0
,
arg1
);
}
else
}
else
fetchadd
(
&
cilk_frame
()
->
ref
,
1
)
;
cilk_frame
()
->
ref
++
;
}
}
// Try to execute one cilkthread.
// Try to execute one cilkthread.
...
@@ -248,7 +248,7 @@ cilk_end(void)
...
@@ -248,7 +248,7 @@ cilk_end(void)
}
}
}
}
}
}
mycpu
()
->
cilkframe
=
NULL
;
mycpu
()
->
cilkframe
=
0
;
popcli
();
popcli
();
}
}
...
@@ -281,7 +281,7 @@ testcilk(void)
...
@@ -281,7 +281,7 @@ testcilk(void)
s
=
rdtsc
();
s
=
rdtsc
();
cilk_start
();
cilk_start
();
for
(
i
=
0
;
i
<
iters
;
i
++
)
for
(
i
=
0
;
i
<
iters
;
i
++
)
cilk_push
(
__test_stub
,
i
,
i
);
cilk_push
(
(
void
*
)
__test_stub
,
i
,
i
);
cilk_end
();
cilk_end
();
e
=
rdtsc
();
e
=
rdtsc
();
cprintf
(
"testcilk: %lu
\n
"
,
(
e
-
s
)
/
iters
);
cprintf
(
"testcilk: %lu
\n
"
,
(
e
-
s
)
/
iters
);
...
...
lib.h
浏览文件 @
2eb42789
...
@@ -18,11 +18,7 @@
...
@@ -18,11 +18,7 @@
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
#define cmpswap(ptr, old, new) __sync_bool_compare_and_swap(ptr, old, new)
#define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val)
#define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val)
#define __offsetof offsetof
#define __offsetof offsetof
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
#define __noret__ __attribute__((noreturn))
#define __noret__ __attribute__((noreturn))
proc.hh
浏览文件 @
2eb42789
#include "spinlock.h"
#include "spinlock.h"
#include "atomic.hh"
// Saved registers for kernel context switches.
// Saved registers for kernel context switches.
// (also implicitly defined in swtch.S)
// (also implicitly defined in swtch.S)
...
@@ -14,7 +15,7 @@ struct context {
...
@@ -14,7 +15,7 @@ struct context {
// Work queue frame
// Work queue frame
struct
cilkframe
{
struct
cilkframe
{
volatile
u64
ref
;
volatile
std
::
atomic
<
u64
>
ref
;
};
};
// Per-process, per-stack meta data for mtrace
// Per-process, per-stack meta data for mtrace
...
...
qlock.h
浏览文件 @
2eb42789
...
@@ -12,7 +12,7 @@ typedef struct {
...
@@ -12,7 +12,7 @@ typedef struct {
static
inline
void
static
inline
void
ql_init
(
qlock_t
*
l
,
const
char
*
name
)
ql_init
(
qlock_t
*
l
,
const
char
*
name
)
{
{
l
->
v
=
NULL
;
l
->
v
=
0
;
l
->
name
=
name
;
l
->
name
=
name
;
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论