Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
f2b96eaa
提交
f2b96eaa
5月 19, 2011
创建
作者:
Robert Morris
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'scale' of
git+ssh://pdos.csail.mit.edu/home/am0/6.828/xv6
into scale
上级
e661e06a
e7260cf3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
4 行删除
+38
-4
defs.h
defs.h
+1
-0
exec.c
exec.c
+2
-1
proc.c
proc.c
+35
-3
没有找到文件。
defs.h
浏览文件 @
f2b96eaa
...
...
@@ -115,6 +115,7 @@ void sched(void);
void
userinit
(
void
);
int
wait
(
void
);
void
yield
(
void
);
void
migrate
(
void
);
// swtch.S
void
swtch
(
struct
context
**
,
struct
context
*
);
...
...
exec.c
浏览文件 @
f2b96eaa
...
...
@@ -125,7 +125,8 @@ exec(char *path, char **argv)
switchuvm
(
proc
);
vmap_decref
(
oldvmap
);
// XXX migrate to another core??
migrate
();
return
0
;
bad:
...
...
proc.c
浏览文件 @
f2b96eaa
...
...
@@ -11,6 +11,7 @@
struct
ptable
ptables
[
NCPU
];
struct
runq
runqs
[
NCPU
];
int
idle
[
NCPU
];
static
struct
proc
*
initproc
;
extern
void
forkret
(
void
);
...
...
@@ -23,6 +24,9 @@ pinit(void)
int
i
;
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
idle
[
c
]
=
1
;
ptables
[
c
].
nextpid
=
(
c
<<
16
)
|
(
1
);
ptables
[
c
].
name
[
0
]
=
(
char
)
(
c
+
'0'
);
safestrcpy
(
ptables
[
c
].
name
+
1
,
"ptable"
,
MAXNAME
-
1
);
...
...
@@ -402,7 +406,31 @@ wait(void)
}
}
void
void
migrate
(
void
)
{
int
c
;
struct
proc
*
p
;
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
if
(
c
==
cpunum
())
continue
;
if
(
idle
[
c
])
{
// OK if there is a race
cprintf
(
"migrate to %d
\n
"
,
c
);
p
=
proc
;
p
->
curcycles
=
0
;
p
->
cpuid
=
c
;
addrun
(
p
);
acquire
(
&
p
->
lock
);
p
->
state
=
RUNNABLE
;
sched
();
release
(
&
proc
->
lock
);
return
;
}
}
}
int
steal
(
void
)
{
int
c
;
...
...
@@ -422,11 +450,12 @@ steal(void)
p
->
curcycles
=
0
;
p
->
cpuid
=
cpu
->
id
;
addrun
(
p
);
return
;
return
1
;
}
}
release
(
&
runqs
[
c
].
lock
);
}
return
0
;
}
//PAGEBREAK: 42
...
...
@@ -464,6 +493,8 @@ scheduler(void)
panic
(
"non-runnable process on runq
\n
"
);
STAILQ_REMOVE
(
&
runq
->
runq
,
p
,
proc
,
run_next
);
if
(
idle
[
cpu
->
id
])
idle
[
cpu
->
id
]
=
0
;
release
(
&
runq
->
lock
);
// Switch to chosen process. It is the process's job
...
...
@@ -491,7 +522,8 @@ scheduler(void)
if
(
p
==
0
)
{
release
(
&
runq
->
lock
);
steal
();
if
(
!
steal
())
idle
[
cpu
->
id
]
=
1
;
}
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论