Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
da74da16
提交
da74da16
3月 15, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start of a thread pool for uwq
上级
352865e7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
56 行增加
和
3 行删除
+56
-3
uwq.hh
include/uwq.hh
+13
-1
uwq.cc
kernel/uwq.cc
+43
-2
没有找到文件。
include/uwq.hh
浏览文件 @
da74da16
...
...
@@ -9,12 +9,24 @@ struct padded_length {
struct
uwq
{
uwq
(
padded_length
*
len
);
~
uwq
();
bool
haswork
();
bool
haswork
();
int
trywork
();
void
*
buffer
();
private
:
uwq
&
operator
=
(
const
uwq
&
);
uwq
(
const
uwq
&
x
);
proc
*
getworker
();
struct
spinlock
lock_
;
padded_length
*
len_
;
struct
worker
{
int
running
;
proc
*
proc
;
};
worker
worker_
[
NCPU
];
};
int
uwq_trywork
(
void
);
...
...
kernel/uwq.cc
浏览文件 @
da74da16
...
...
@@ -2,11 +2,11 @@
#include "amd64.h"
#include "kernel.hh"
#include "cpu.hh"
#include "uwq.hh"
#include "gc.hh"
#include "percpu.hh"
#include "spinlock.h"
#include "condvar.h"
#include "uwq.hh"
#include "proc.hh"
#include "vm.hh"
#include "kalloc.hh"
...
...
@@ -25,13 +25,15 @@ uwq_trywork(void)
continue
;
struct
cpu
*
c
=
&
cpus
[
j
];
scoped_gc_epoch
();
scoped_gc_epoch
gcx
();
barrier
();
struct
proc
*
p
=
c
->
proc
;
if
(
p
==
nullptr
||
p
->
vmap
==
nullptr
)
continue
;
uwq
*
uwq
=
&
p
->
vmap
->
uwq_
;
if
(
uwq
->
haswork
())
{
uwq
->
trywork
();
// XXX(sbw) start a worker thread..
break
;
}
...
...
@@ -52,6 +54,9 @@ uwq::uwq(padded_length *len)
}
else
{
cprintf
(
"uwq::uwq: nullptr len
\n
"
);
}
initlock
(
&
lock_
,
"uwq_lock"
,
0
);
memset
(
worker_
,
0
,
sizeof
(
worker_
));
}
uwq
::~
uwq
(
void
)
...
...
@@ -74,8 +79,44 @@ uwq::haswork(void)
return
false
;
}
int
uwq
::
trywork
(
void
)
{
struct
proc
*
p
;
p
=
getworker
();
if
(
p
==
nullptr
)
return
-
1
;
return
0
;
}
void
*
uwq
::
buffer
(
void
)
{
return
(
void
*
)
len_
;
}
proc
*
uwq
::
getworker
(
void
)
{
int
slot
=
-
1
;
scoped_acquire
lockx
(
&
lock_
);
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
{
if
(
worker_
[
i
].
proc
!=
nullptr
)
{
worker_
[
i
].
running
=
1
;
return
worker_
[
i
].
proc
;
}
else
if
(
slot
==
-
1
)
{
slot
=
i
;
}
}
if
(
slot
!=
-
1
)
{
panic
(
"XXX"
);
}
return
nullptr
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论