Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
b4b33f85
提交
b4b33f85
3月 18, 2012
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add sys_setaffinity syscall
上级
37d6db3b
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
41 行增加
和
8 行删除
+41
-8
kern_c.h
include/kern_c.h
+1
-0
proc.hh
include/proc.hh
+2
-0
syscall.h
include/syscall.h
+2
-1
user.h
include/user.h
+1
-0
wquser.hh
include/wquser.hh
+0
-6
bootdata.c
kernel/bootdata.c
+1
-0
proc.cc
kernel/proc.cc
+24
-0
sched.cc
kernel/sched.cc
+3
-1
sysproc.cc
kernel/sysproc.cc
+6
-0
usys.S
lib/usys.S
+1
-0
没有找到文件。
include/kern_c.h
浏览文件 @
b4b33f85
...
@@ -51,6 +51,7 @@ long sys_pread(int fd, void *ubuf, size_t count, off_t offset);
...
@@ -51,6 +51,7 @@ long sys_pread(int fd, void *ubuf, size_t count, off_t offset);
long
sys_async
(
int
,
size_t
,
off_t
,
u32
,
u32
);
long
sys_async
(
int
,
size_t
,
off_t
,
u32
,
u32
);
long
sys_script
(
void
*
addr
,
u64
len
,
u64
chunk
);
long
sys_script
(
void
*
addr
,
u64
len
,
u64
chunk
);
long
sys_setfs
(
u64
base
);
long
sys_setfs
(
u64
base
);
long
sys_setaffinity
(
int
cpu
);
extern
long
(
*
syscalls
[])(
u64
,
u64
,
u64
,
u64
,
u64
);
extern
long
(
*
syscalls
[])(
u64
,
u64
,
u64
,
u64
,
u64
);
// other exported/imported functions
// other exported/imported functions
...
...
include/proc.hh
浏览文件 @
b4b33f85
...
@@ -84,6 +84,8 @@ struct proc : public rcu_freed {
...
@@ -84,6 +84,8 @@ struct proc : public rcu_freed {
void
set_state
(
enum
procstate
s
);
void
set_state
(
enum
procstate
s
);
enum
procstate
get_state
(
void
)
const
{
return
state_
;
}
enum
procstate
get_state
(
void
)
const
{
return
state_
;
}
int
set_cpu_pin
(
int
cpu
);
private
:
private
:
enum
procstate
state_
;
// Process state
enum
procstate
state_
;
// Process state
};
};
include/syscall.h
浏览文件 @
b4b33f85
...
@@ -31,4 +31,5 @@
...
@@ -31,4 +31,5 @@
#define SYS_async 30
#define SYS_async 30
#define SYS_script 31
#define SYS_script 31
#define SYS_setfs 32
#define SYS_setfs 32
#define SYS_ncount 33
/* total number of system calls */
#define SYS_setaffinity 33
#define SYS_ncount 34
/* total number of system calls */
include/user.h
浏览文件 @
b4b33f85
...
@@ -31,6 +31,7 @@ ssize_t pread(int, void*, size_t, off_t);
...
@@ -31,6 +31,7 @@ ssize_t pread(int, void*, size_t, off_t);
int
async
(
int
,
size_t
,
off_t
,
u32
,
u32
);
int
async
(
int
,
size_t
,
off_t
,
u32
,
u32
);
int
script
(
void
*
addr
,
u64
len
,
u64
chunk
);
int
script
(
void
*
addr
,
u64
len
,
u64
chunk
);
int
setfs
(
u64
base
);
int
setfs
(
u64
base
);
int
setaffinity
(
int
cpu
);
// ulib.c
// ulib.c
int
stat
(
char
*
,
struct
stat
*
);
int
stat
(
char
*
,
struct
stat
*
);
...
...
include/wquser.hh
浏览文件 @
b4b33f85
...
@@ -46,12 +46,6 @@ wqlock_init(wqlock_t *lock)
...
@@ -46,12 +46,6 @@ wqlock_init(wqlock_t *lock)
initlock
(
lock
);
initlock
(
lock
);
}
}
static
void
setaffinity
(
int
c
)
{
// XXX(sbw)
}
static
void
*
static
void
*
workerth
(
void
*
x
)
workerth
(
void
*
x
)
{
{
...
...
kernel/bootdata.c
浏览文件 @
b4b33f85
...
@@ -61,5 +61,6 @@ long (*syscalls[])(u64, u64, u64, u64, u64) = {
...
@@ -61,5 +61,6 @@ long (*syscalls[])(u64, u64, u64, u64, u64) = {
SYSCALL
(
async
),
SYSCALL
(
async
),
SYSCALL
(
script
),
SYSCALL
(
script
),
SYSCALL
(
setfs
),
SYSCALL
(
setfs
),
SYSCALL
(
setaffinity
),
};
};
kernel/proc.cc
浏览文件 @
b4b33f85
...
@@ -85,6 +85,30 @@ proc::set_state(enum procstate s)
...
@@ -85,6 +85,30 @@ proc::set_state(enum procstate s)
state_
=
s
;
state_
=
s
;
}
}
int
proc
::
set_cpu_pin
(
int
cpu
)
{
if
(
cpu
<
-
1
||
cpu
>=
ncpu
)
return
-
1
;
acquire
(
&
lock
);
if
(
myproc
()
!=
this
)
panic
(
"set_cpu_pin not implemented for non-current proc"
);
if
(
cpu
==
-
1
)
{
cpu_pin
=
0
;
release
(
&
lock
);
return
0
;
}
// Since we're the current proc, there's no runq to get off.
// post_swtch will put us on the new runq.
cpuid
=
cpu
;
cpu_pin
=
1
;
myproc
()
->
set_state
(
RUNNABLE
);
sched
();
assert
(
mycpu
()
->
id
==
cpu
);
return
0
;
}
// Give up the CPU for one scheduling round.
// Give up the CPU for one scheduling round.
void
void
yield
(
void
)
yield
(
void
)
...
...
kernel/sched.cc
浏览文件 @
b4b33f85
...
@@ -60,7 +60,9 @@ sched(void)
...
@@ -60,7 +60,9 @@ sched(void)
struct
proc
*
next
=
schednext
();
struct
proc
*
next
=
schednext
();
if
(
next
==
nullptr
)
{
if
(
next
==
nullptr
)
{
if
(
myproc
()
->
get_state
()
!=
RUNNABLE
)
{
if
(
myproc
()
->
get_state
()
!=
RUNNABLE
||
// proc changed its CPU pin?
myproc
()
->
cpuid
!=
mycpu
()
->
id
)
{
next
=
idleproc
();
next
=
idleproc
();
}
else
{
}
else
{
myproc
()
->
set_state
(
RUNNING
);
myproc
()
->
set_state
(
RUNNING
);
...
...
kernel/sysproc.cc
浏览文件 @
b4b33f85
...
@@ -131,3 +131,9 @@ sys_setfs(u64 base)
...
@@ -131,3 +131,9 @@ sys_setfs(u64 base)
switchvm
(
p
);
switchvm
(
p
);
return
0
;
return
0
;
}
}
long
sys_setaffinity
(
int
cpu
)
{
return
myproc
()
->
set_cpu_pin
(
cpu
);
}
lib/usys.S
浏览文件 @
b4b33f85
...
@@ -48,3 +48,4 @@ SYSCALL(pread)
...
@@ -48,3 +48,4 @@ SYSCALL(pread)
SYSCALL(async)
SYSCALL(async)
SYSCALL(script)
SYSCALL(script)
SYSCALL(setfs)
SYSCALL(setfs)
SYSCALL(setaffinity)
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论