Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
7af1706b
提交
7af1706b
4月 11, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More usched
上级
98c1ea02
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
7 行删除
+21
-7
usched.cc
user/usched.cc
+21
-7
没有找到文件。
user/usched.cc
浏览文件 @
7af1706b
...
...
@@ -14,6 +14,11 @@ typedef uint64_t u64;
#include "percpu.hh"
#include "sched.hh"
#include "queue.h"
#include "uscopedperf.hh"
#include "intelctr.hh"
static
auto
perfgroup
=
ctrgroup
(
&
intelctr
::
tsc
);
static
int
nprocs
=
NCPU
;
static
int
the_time
=
5
;
...
...
@@ -64,13 +69,14 @@ public:
proc
*
steal
(
bool
nonexec
);
void
dump
();
volatile
u64
ncansteal_
__mpalign__
;
sched_stat
stats_
;
u64
ncansteal_
;
volatile
bool
cansteal_
__mpalign__
;
private
:
pthread_spinlock_t
lock_
;
sched_link
head_
;
sched_link
head_
__mpalign__
;
;
};
percpu
<
schedule
>
schedule_
;
...
...
@@ -109,6 +115,7 @@ schedule::schedule(void)
head_
.
next
=
&
head_
;
head_
.
prev
=
&
head_
;
ncansteal_
=
0
;
cansteal_
=
false
;
pthread_spin_init
(
&
lock_
,
0
);
}
...
...
@@ -123,7 +130,8 @@ schedule::enq(proc* p)
head_
.
prev
->
next
=
entry
;
head_
.
prev
=
entry
;
if
(
cansteal
((
proc
*
)
entry
,
true
))
ncansteal_
++
;
if
(
ncansteal_
++
==
0
)
cansteal_
=
true
;
stats_
.
enqs
++
;
pthread_spin_unlock
(
&
lock_
);
}
...
...
@@ -131,6 +139,8 @@ schedule::enq(proc* p)
proc
*
schedule
::
deq
(
void
)
{
ANON_REGION
(
"deq"
,
&
perfgroup
);
if
(
head_
.
next
==
&
head_
)
return
nullptr
;
...
...
@@ -145,7 +155,8 @@ schedule::deq(void)
entry
->
next
->
prev
=
entry
->
prev
;
entry
->
prev
->
next
=
entry
->
next
;
if
(
cansteal
((
proc
*
)
entry
,
true
))
--
ncansteal_
;
if
(
--
ncansteal_
==
0
)
cansteal_
=
false
;
stats_
.
deqs
++
;
pthread_spin_unlock
(
&
lock_
);
return
(
proc
*
)
entry
;
...
...
@@ -154,14 +165,15 @@ schedule::deq(void)
proc
*
schedule
::
steal
(
bool
nonexec
)
{
if
(
ncansteal_
==
0
||
pthread_spin_trylock
(
&
lock_
))
if
(
!
cansteal_
||
pthread_spin_trylock
(
&
lock_
))
return
nullptr
;
for
(
sched_link
*
ptr
=
head_
.
next
;
ptr
!=
&
head_
;
ptr
=
ptr
->
next
)
if
(
cansteal
((
proc
*
)
ptr
,
nonexec
))
{
ptr
->
next
->
prev
=
ptr
->
prev
;
ptr
->
prev
->
next
=
ptr
->
next
;
--
ncansteal_
;
if
(
--
ncansteal_
==
0
)
cansteal_
=
false
;
++
stats_
.
steals
;
pthread_spin_unlock
(
&
lock_
);
return
(
proc
*
)
ptr
;
...
...
@@ -187,6 +199,7 @@ stealit(void)
{
proc
*
p
;
ANON_REGION
(
"stealit"
,
&
perfgroup
);
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
{
if
(
i
==
myid_
)
continue
;
...
...
@@ -269,5 +282,6 @@ main(int ac, char** av)
sleep
(
1
);
worker
((
void
*
)
0
);
scopedperf
::
perfsum_base
::
printall
();
return
0
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论