Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
df8678a7
提交
df8678a7
5月 02, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xthread_create takes fork flags
上级
f838a215
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
1 行删除
+24
-1
mapbench.cc
bin/mapbench.cc
+3
-1
pthread.h
include/pthread.h
+4
-0
xsys.h
include/xsys.h
+3
-0
threads.cc
lib/threads.cc
+14
-0
没有找到文件。
bin/mapbench.cc
浏览文件 @
df8678a7
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "uspinlock.h"
#include "uspinlock.h"
#include "mtrace.h"
#include "mtrace.h"
#include "pthread.h"
#include "pthread.h"
#include "fcntl.h"
#endif
#endif
#include "xsys.h"
#include "xsys.h"
#include <sys/mman.h>
#include <sys/mman.h>
...
@@ -20,6 +21,7 @@
...
@@ -20,6 +21,7 @@
enum
{
readaccess
=
1
};
enum
{
readaccess
=
1
};
enum
{
verbose
=
0
};
enum
{
verbose
=
0
};
enum
{
npg
=
1
};
enum
{
npg
=
1
};
enum
{
xthread_flags
=
FORK_SEPARATE_PGMAP
};
static
pthread_barrier_t
bar
;
static
pthread_barrier_t
bar
;
static
pthread_barrier_t
bar2
;
static
pthread_barrier_t
bar2
;
...
@@ -79,7 +81,7 @@ main(int ac, char **av)
...
@@ -79,7 +81,7 @@ main(int ac, char **av)
pthread_barrier_init
(
&
bar2
,
0
,
nthread
);
pthread_barrier_init
(
&
bar2
,
0
,
nthread
);
for
(
u64
i
=
0
;
i
<
nthread
;
i
++
)
{
for
(
u64
i
=
0
;
i
<
nthread
;
i
++
)
{
pthread_create
(
&
tid
[
i
],
0
,
thr
,
(
void
*
)
i
);
xthread_create
(
&
tid
[
i
],
xthread_flags
,
thr
,
(
void
*
)
i
);
if
(
0
)
printf
(
"mapbench[%d]: child %d
\n
"
,
getpid
(),
tid
);
if
(
0
)
printf
(
"mapbench[%d]: child %d
\n
"
,
getpid
(),
tid
);
}
}
...
...
include/pthread.h
浏览文件 @
df8678a7
...
@@ -24,3 +24,7 @@ int pthread_barrier_init(pthread_barrier_t *b,
...
@@ -24,3 +24,7 @@ int pthread_barrier_init(pthread_barrier_t *b,
const
pthread_barrierattr_t
*
attr
,
const
pthread_barrierattr_t
*
attr
,
unsigned
count
);
unsigned
count
);
int
pthread_barrier_wait
(
pthread_barrier_t
*
b
);
int
pthread_barrier_wait
(
pthread_barrier_t
*
b
);
// Special xv6 pthread_create, flags is FORK_* bits
int
xthread_create
(
pthread_t
*
tid
,
int
flags
,
void
*
(
*
start
)(
void
*
),
void
*
arg
);
include/xsys.h
浏览文件 @
df8678a7
#if defined(LINUX)
#if defined(LINUX)
#define O_CREATE O_CREAT
#define O_CREATE O_CREAT
#define FORK_SEPARATE_PGMAP 0
#define xfork() fork()
#define xfork() fork()
#define xexit() exit(EXIT_SUCCESS)
#define xexit() exit(EXIT_SUCCESS)
static
inline
void
xwait
()
static
inline
void
xwait
()
...
@@ -17,6 +18,8 @@ static inline void xwait()
...
@@ -17,6 +18,8 @@ static inline void xwait()
#define mtenable_type(x, y) do { } while (0)
#define mtenable_type(x, y) do { } while (0)
#define mtdisable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#define xpthread_join(tid) pthread_join(tid, nullptr);
#define xpthread_join(tid) pthread_join(tid, nullptr);
#define xthread_create(ptr, x, fn, arg) \
pthread_create((ptr), 0, (fn), (arg))
#else // Must be xv6
#else // Must be xv6
...
...
lib/threads.cc
浏览文件 @
df8678a7
...
@@ -31,6 +31,20 @@ pthread_create(pthread_t* tid, const pthread_attr_t* attr,
...
@@ -31,6 +31,20 @@ pthread_create(pthread_t* tid, const pthread_attr_t* attr,
return
0
;
return
0
;
}
}
int
xthread_create
(
pthread_t
*
tid
,
int
flags
,
void
*
(
*
start
)(
void
*
),
void
*
arg
)
{
char
*
base
=
(
char
*
)
sbrk
(
stack_size
);
int
t
=
forkt
(
base
+
stack_size
,
(
void
*
)
start
,
arg
,
FORK_SHARE_VMAP
|
FORK_SHARE_FD
|
flags
);
if
(
t
<
0
)
return
t
;
*
tid
=
t
;
return
0
;
}
pthread_t
pthread_t
pthread_self
()
pthread_self
()
{
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论