Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9583b476
提交
9583b476
8月 09, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
try to use cp only for curproc[cpu()]
上级
22330658
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
36 行删除
+37
-36
proc.c
proc.c
+9
-9
syscall.c
syscall.c
+9
-9
sysfile.c
sysfile.c
+12
-11
umalloc.c
umalloc.c
+7
-7
没有找到文件。
proc.c
浏览文件 @
9583b476
...
...
@@ -204,9 +204,9 @@ scheduler(void)
void
sched
(
void
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
if
(
p
->
state
==
RUNNING
)
if
(
c
p
->
state
==
RUNNING
)
panic
(
"sched running"
);
if
(
!
holding
(
&
proc_table_lock
))
panic
(
"sched proc_table_lock"
);
...
...
@@ -221,10 +221,10 @@ sched(void)
void
yield
(
void
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
acquire
(
&
proc_table_lock
);
p
->
state
=
RUNNABLE
;
c
p
->
state
=
RUNNABLE
;
sched
();
release
(
&
proc_table_lock
);
}
...
...
@@ -246,9 +246,9 @@ forkret(void)
void
sleep
(
void
*
chan
,
struct
spinlock
*
lk
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
if
(
p
==
0
)
if
(
c
p
==
0
)
panic
(
"sleep"
);
if
(
lk
==
0
)
...
...
@@ -266,12 +266,12 @@ sleep(void *chan, struct spinlock *lk)
}
// Go to sleep.
p
->
chan
=
chan
;
p
->
state
=
SLEEPING
;
c
p
->
chan
=
chan
;
c
p
->
state
=
SLEEPING
;
sched
();
// Tidy up.
p
->
chan
=
0
;
c
p
->
chan
=
0
;
// Reacquire original lock.
if
(
lk
!=
&
proc_table_lock
){
...
...
syscall.c
浏览文件 @
9583b476
...
...
@@ -37,15 +37,15 @@ fetchint(struct proc *p, uint addr, int *ip)
int
fetchstr
(
struct
proc
*
p
,
uint
addr
,
char
**
pp
)
{
char
*
cp
,
*
ep
;
char
*
s
,
*
ep
;
if
(
addr
>=
p
->
sz
)
return
-
1
;
*
pp
=
p
->
mem
+
addr
;
ep
=
p
->
mem
+
p
->
sz
;
for
(
cp
=
*
pp
;
cp
<
ep
;
cp
++
)
if
(
*
cp
==
0
)
return
cp
-
*
pp
;
for
(
s
=
*
pp
;
s
<
ep
;
s
++
)
if
(
*
s
==
0
)
return
s
-
*
pp
;
return
-
1
;
}
...
...
@@ -53,9 +53,9 @@ fetchstr(struct proc *p, uint addr, char **pp)
int
argint
(
int
argno
,
int
*
ip
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
return
fetchint
(
p
,
p
->
tf
->
esp
+
4
+
4
*
argno
,
ip
);
return
fetchint
(
cp
,
c
p
->
tf
->
esp
+
4
+
4
*
argno
,
ip
);
}
// Fetch the nth word-sized system call argument as a pointer
...
...
@@ -65,13 +65,13 @@ int
argptr
(
int
argno
,
char
**
pp
,
int
size
)
{
int
i
;
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
if
(
argint
(
argno
,
&
i
)
<
0
)
return
-
1
;
if
((
uint
)
i
>=
p
->
sz
||
(
uint
)
i
+
size
>=
p
->
sz
)
if
((
uint
)
i
>=
cp
->
sz
||
(
uint
)
i
+
size
>=
c
p
->
sz
)
return
-
1
;
*
pp
=
p
->
mem
+
i
;
*
pp
=
c
p
->
mem
+
i
;
return
0
;
}
...
...
sysfile.c
浏览文件 @
9583b476
...
...
@@ -22,11 +22,11 @@ argfd(int argno, int *pfd, struct file **pf)
{
int
fd
;
struct
file
*
f
;
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
if
(
argint
(
argno
,
&
fd
)
<
0
)
return
-
1
;
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
p
->
ofile
[
fd
])
==
0
)
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
c
p
->
ofile
[
fd
])
==
0
)
return
-
1
;
if
(
pfd
)
*
pfd
=
fd
;
...
...
@@ -41,10 +41,11 @@ static int
fdalloc
(
struct
file
*
f
)
{
int
fd
;
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
cp
=
curproc
[
cpu
()];
for
(
fd
=
0
;
fd
<
NOFILE
;
fd
++
){
if
(
p
->
ofile
[
fd
]
==
0
){
p
->
ofile
[
fd
]
=
f
;
if
(
c
p
->
ofile
[
fd
]
==
0
){
c
p
->
ofile
[
fd
]
=
f
;
return
fd
;
}
}
...
...
@@ -57,7 +58,7 @@ sys_pipe(void)
int
*
fd
;
struct
file
*
rf
=
0
,
*
wf
=
0
;
int
fd0
,
fd1
;
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
if
(
argptr
(
0
,
(
void
*
)
&
fd
,
2
*
sizeof
fd
[
0
])
<
0
)
return
-
1
;
...
...
@@ -66,7 +67,7 @@ sys_pipe(void)
fd0
=
-
1
;
if
((
fd0
=
fdalloc
(
rf
))
<
0
||
(
fd1
=
fdalloc
(
wf
))
<
0
){
if
(
fd0
>=
0
)
p
->
ofile
[
fd0
]
=
0
;
c
p
->
ofile
[
fd0
]
=
0
;
fileclose
(
rf
);
fileclose
(
wf
);
return
-
1
;
...
...
@@ -241,7 +242,7 @@ sys_mkdir(void)
int
sys_chdir
(
void
)
{
struct
proc
*
p
=
curproc
[
cpu
()];
struct
proc
*
c
p
=
curproc
[
cpu
()];
struct
inode
*
ip
;
char
*
path
;
...
...
@@ -261,9 +262,9 @@ sys_chdir(void)
return
-
1
;
}
idecref
(
p
->
cwd
);
p
->
cwd
=
ip
;
iunlock
(
p
->
cwd
);
idecref
(
c
p
->
cwd
);
c
p
->
cwd
=
ip
;
iunlock
(
c
p
->
cwd
);
return
0
;
}
...
...
umalloc.c
浏览文件 @
9583b476
...
...
@@ -46,17 +46,17 @@ free(void *ap)
static
Header
*
morecore
(
uint
nu
)
{
char
*
c
p
;
Header
*
u
p
;
char
*
p
;
Header
*
h
p
;
if
(
nu
<
PAGE
)
nu
=
PAGE
;
c
p
=
sbrk
(
nu
*
sizeof
(
Header
));
if
(
c
p
==
(
char
*
)
-
1
)
p
=
sbrk
(
nu
*
sizeof
(
Header
));
if
(
p
==
(
char
*
)
-
1
)
return
0
;
up
=
(
Header
*
)
c
p
;
u
p
->
s
.
size
=
nu
;
free
((
void
*
)(
u
p
+
1
));
hp
=
(
Header
*
)
p
;
h
p
->
s
.
size
=
nu
;
free
((
void
*
)(
h
p
+
1
));
return
freep
;
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论