Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
fe8f6fc2
提交
fe8f6fc2
6月 11, 2011
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hlt when idle
上级
4fe2d66d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
12 行删除
+25
-12
proc.c
proc.c
+20
-12
x86.h
x86.h
+5
-0
没有找到文件。
proc.c
浏览文件 @
fe8f6fc2
...
...
@@ -112,7 +112,7 @@ addrun(struct proc *p)
if
(
!
holding
(
&
p
->
lock
))
panic
(
"addrun no p->lock"
);
acquire
(
&
runqs
[
p
->
cpuid
].
lock
);
// cprintf("%d: addrun %d\n", cpu
num()
, p->pid);
// cprintf("%d: addrun %d\n", cpu
->id
, p->pid);
addrun1
(
&
runqs
[
p
->
cpuid
],
p
);
release
(
&
runqs
[
p
->
cpuid
].
lock
);
}
...
...
@@ -136,7 +136,7 @@ delrun(struct proc *p)
if
(
!
holding
(
&
p
->
lock
))
panic
(
"delrun no p->lock"
);
acquire
(
&
runq
->
lock
);
// cprintf("%d: delrun %d\n", cpu
num()
, p->pid);
// cprintf("%d: delrun %d\n", cpu
->id
, p->pid);
delrun1
(
runq
,
p
);
release
(
&
runq
->
lock
);
}
...
...
@@ -423,7 +423,7 @@ migrate(void)
struct
proc
*
p
;
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
if
(
c
==
cpu
num
()
)
if
(
c
==
cpu
->
id
)
continue
;
if
(
idle
[
c
])
{
// OK if there is a race
// cprintf("migrate to %d\n", c);
...
...
@@ -446,7 +446,7 @@ steal(void)
struct
proc
*
p
;
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
if
(
c
==
cpu
num
()
)
if
(
c
==
cpu
->
id
)
continue
;
acquire
(
&
runqs
[
c
].
lock
);
STAILQ_FOREACH
(
p
,
&
runqs
[
c
].
runq
,
run_next
)
{
...
...
@@ -454,7 +454,7 @@ steal(void)
if
(
p
->
state
!=
RUNNABLE
)
panic
(
"non-runnable proc on runq"
);
if
(
p
->
curcycles
==
0
||
p
->
curcycles
>
MINCYCTHRESH
)
{
// cprintf("%d: steal %d (%d) from %d\n", cpu
num()
, p->pid, p->curcycles, c);
// cprintf("%d: steal %d (%d) from %d\n", cpu
->id
, p->pid, p->curcycles, c);
delrun1
(
&
runqs
[
c
],
p
);
release
(
&
runqs
[
c
].
lock
);
p
->
curcycles
=
0
;
...
...
@@ -487,7 +487,7 @@ scheduler(void)
pid
=
ns_allockey
(
nspid
);
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpu
num()
);
// mtrace_call_set(1, cpu
->id
);
mtrace_fcall_register
(
pid
,
(
unsigned
long
)
scheduler
,
0
,
mtrace_start
);
for
(;;){
...
...
@@ -520,10 +520,10 @@ scheduler(void)
mtrace_fcall_register
(
pid
,
0
,
0
,
mtrace_pause
);
mtrace_fcall_register
(
proc
->
pid
,
0
,
0
,
mtrace_resume
);
mtrace_call_set
(
1
,
cpu
num
()
);
mtrace_call_set
(
1
,
cpu
->
id
);
swtch
(
&
cpu
->
scheduler
,
proc
->
context
);
mtrace_fcall_register
(
pid
,
0
,
0
,
mtrace_resume
);
mtrace_call_set
(
0
,
cpu
num
()
);
mtrace_call_set
(
0
,
cpu
->
id
);
switchkvm
();
// Process is done running for now.
...
...
@@ -535,11 +535,19 @@ scheduler(void)
if
(
p
==
0
)
{
release
(
&
runq
->
lock
);
if
(
!
steal
()
&&
!
idle
[
cpu
->
id
])
{
// cprintf("%d: idle\n", cpu->id);
idle
[
cpu
->
id
]
=
1
;
if
(
steal
())
{
if
(
idle
[
cpu
->
id
])
idle
[
cpu
->
id
]
=
0
;
}
else
{
if
(
!
idle
[
cpu
->
id
])
idle
[
cpu
->
id
]
=
1
;
}
}
if
(
idle
[
cpu
->
id
])
{
sti
();
hlt
();
}
}
}
...
...
@@ -561,7 +569,7 @@ sched(void)
intena
=
cpu
->
intena
;
proc
->
curcycles
+=
rdtsc
()
-
proc
->
tsc
;
mtrace_fcall_register
(
proc
->
pid
,
0
,
0
,
mtrace_pause
);
mtrace_call_set
(
0
,
cpu
num
()
);
mtrace_call_set
(
0
,
cpu
->
id
);
swtch
(
&
proc
->
context
,
cpu
->
scheduler
);
cpu
->
intena
=
intena
;
...
...
x86.h
浏览文件 @
fe8f6fc2
...
...
@@ -212,6 +212,11 @@ static __inline__ unsigned long long rdtsc(void)
return
(
(
unsigned
long
long
)
lo
)
|
(
((
unsigned
long
long
)
hi
)
<<
32
);
}
static
__inline__
void
hlt
(
void
)
{
__asm__
__volatile__
(
"hlt"
);
}
//PAGEBREAK: 36
// Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap().
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论