Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
893b2640
提交
893b2640
3月 22, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More worker clean up
上级
6fb6add0
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
34 行增加
和
45 行删除
+34
-45
uwq.hh
include/uwq.hh
+6
-7
wq.hh
include/wq.hh
+0
-4
idle.cc
kernel/idle.cc
+2
-3
uwq.cc
kernel/uwq.cc
+26
-31
没有找到文件。
include/uwq.hh
浏览文件 @
893b2640
...
@@ -6,13 +6,15 @@ struct padded_length {
...
@@ -6,13 +6,15 @@ struct padded_length {
};
};
#if defined (XV6_KERNEL)
#if defined (XV6_KERNEL)
#define NWORKERS (NCPU-1)
bool
uwq_trywork
(
void
);
#define NWORKERS (NCPU-1)
struct
uwq
;
struct
uwq
;
struct
uwq_worker
{
struct
uwq_worker
{
uwq_worker
(
uwq
*
,
proc
*
);
uwq_worker
(
uwq
*
,
proc
*
);
long
wait
();
long
wait
();
void
exit
();
uwq
*
uwq_
;
uwq
*
uwq_
;
proc
*
proc_
;
proc
*
proc_
;
...
@@ -24,14 +26,13 @@ struct uwq_worker {
...
@@ -24,14 +26,13 @@ struct uwq_worker {
};
};
struct
uwq
:
public
referenced
,
public
rcu_freed
{
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
);
bool
haswork
();
bool
haswork
();
bool
trywork
();
bool
tryworker
();
void
*
buffer
();
void
setuentry
(
uptr
uentry
);
void
setuentry
(
uptr
uentry
);
// XXX(sbw) should be part of struct worker
void
tryexit
(
uwq_worker
*
w
);
virtual
void
do_gc
(
void
)
{
delete
this
;
}
virtual
void
do_gc
(
void
)
{
delete
this
;
}
...
@@ -58,6 +59,4 @@ private:
...
@@ -58,6 +59,4 @@ private:
uwq_worker
*
worker_
[
NCPU
];
uwq_worker
*
worker_
[
NCPU
];
};
};
int
uwq_trywork
(
void
);
#endif
#endif
include/wq.hh
浏览文件 @
893b2640
...
@@ -9,10 +9,6 @@ size_t wq_size(void);
...
@@ -9,10 +9,6 @@ size_t wq_size(void);
void
initwq
(
void
);
void
initwq
(
void
);
void
exitwq
(
void
);
void
exitwq
(
void
);
#if defined(XV6_KERNEL)
int
uwq_trywork
(
void
);
#endif
struct
work
{
struct
work
{
virtual
void
run
()
=
0
;
virtual
void
run
()
=
0
;
};
};
...
...
kernel/idle.cc
浏览文件 @
893b2640
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "sched.hh"
#include "sched.hh"
#include "percpu.hh"
#include "percpu.hh"
#include "wq.hh"
#include "wq.hh"
#include "uwq.hh"
#include "kmtrace.hh"
#include "kmtrace.hh"
struct
idle
{
struct
idle
{
...
@@ -118,9 +119,7 @@ idleloop(void)
...
@@ -118,9 +119,7 @@ idleloop(void)
idlem
->
heir
=
p
;
idlem
->
heir
=
p
;
}
}
// XXX(sbw) what should be the policy here?
if
(
uwq_trywork
())
worked
=
uwq_trywork
();
if
(
worked
==
1
)
break
;
break
;
worked
=
wq_trywork
();
worked
=
wq_trywork
();
...
...
kernel/uwq.cc
浏览文件 @
893b2640
//
// XXX
// - workers should have a uwq
// - pin workers
#include "types.h"
#include "types.h"
#include "amd64.h"
#include "amd64.h"
#include "kernel.hh"
#include "kernel.hh"
...
@@ -20,9 +15,11 @@ extern "C" {
...
@@ -20,9 +15,11 @@ extern "C" {
#include "kern_c.h"
#include "kern_c.h"
}
}
int
bool
uwq_trywork
(
void
)
uwq_trywork
(
void
)
{
{
// Returning true means uwq added a thread to the run queue
u64
i
,
k
;
u64
i
,
k
;
// A "random" victim CPU
// A "random" victim CPU
...
@@ -34,22 +31,23 @@ uwq_trywork(void)
...
@@ -34,22 +31,23 @@ uwq_trywork(void)
continue
;
continue
;
struct
cpu
*
c
=
&
cpus
[
j
];
struct
cpu
*
c
=
&
cpus
[
j
];
// The gc_epoch is for p and uwq
scoped_gc_epoch
xgc
();
scoped_gc_epoch
xgc
();
barrier
();
barrier
();
struct
proc
*
p
=
c
->
proc
;
struct
proc
*
p
=
c
->
proc
;
if
(
p
==
nullptr
||
p
->
uwq
==
nullptr
)
if
(
p
==
nullptr
||
p
->
uwq
==
nullptr
)
continue
;
continue
;
uwq
*
uwq
=
p
->
uwq
;
uwq
*
uwq
=
p
->
uwq
;
if
(
uwq
->
haswork
())
{
if
(
uwq
->
haswork
())
{
if
(
uwq
->
trywork
())
if
(
uwq
->
tryworker
())
return
1
;
return
true
;
// XXX(sbw) start a worker thread..
break
;
break
;
}
}
}
}
return
0
;
return
false
;
}
}
long
long
...
@@ -72,14 +70,28 @@ uwq_worker::uwq_worker(uwq* u, proc* p)
...
@@ -72,14 +70,28 @@ uwq_worker::uwq_worker(uwq* u, proc* p)
initcondvar
(
&
cv_
,
"worker_cv"
);
initcondvar
(
&
cv_
,
"worker_cv"
);
}
}
void
uwq_worker
::
exit
(
void
)
{
if
(
--
uwq_
->
uref_
==
0
)
gc_delayed
(
uwq_
);
release
(
&
lock_
);
delete
this
;
::
exit
();
}
long
long
uwq_worker
::
wait
(
void
)
uwq_worker
::
wait
(
void
)
{
{
acquire
(
&
lock_
);
acquire
(
&
lock_
);
uwq_
->
tryexit
(
this
);
if
(
uwq_
->
ref
()
==
0
)
this
->
exit
();
running_
=
false
;
running_
=
false
;
cv_sleep
(
&
cv_
,
&
lock_
);
cv_sleep
(
&
cv_
,
&
lock_
);
uwq_
->
tryexit
(
this
);
if
(
uwq_
->
ref
()
==
0
)
this
->
exit
();
release
(
&
lock_
);
release
(
&
lock_
);
return
0
;
return
0
;
}
}
...
@@ -140,18 +152,6 @@ uwq::~uwq(void)
...
@@ -140,18 +152,6 @@ uwq::~uwq(void)
ftable_
->
decref
();
ftable_
->
decref
();
}
}
void
uwq
::
tryexit
(
uwq_worker
*
w
)
{
if
(
ref
()
==
0
)
{
if
(
--
uref_
==
0
)
gc_delayed
(
this
);
release
(
&
w
->
lock_
);
delete
w
;
exit
();
}
}
bool
bool
uwq
::
haswork
(
void
)
uwq
::
haswork
(
void
)
{
{
...
@@ -167,8 +167,9 @@ uwq::haswork(void)
...
@@ -167,8 +167,9 @@ uwq::haswork(void)
}
}
bool
bool
uwq
::
trywork
(
void
)
uwq
::
trywork
er
(
void
)
{
{
// Try to start a worker thread
scoped_acquire
lock0
(
&
lock_
);
scoped_acquire
lock0
(
&
lock_
);
if
(
ref
()
==
0
)
if
(
ref
()
==
0
)
...
@@ -249,12 +250,6 @@ uwq::onzero() const
...
@@ -249,12 +250,6 @@ uwq::onzero() const
u
->
finish
();
u
->
finish
();
}
}
void
*
uwq
::
buffer
(
void
)
{
return
(
void
*
)
len_
;
}
void
void
uwq
::
setuentry
(
uptr
uentry
)
uwq
::
setuentry
(
uptr
uentry
)
{
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论