Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
b6095304
提交
b6095304
8月 10, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make cp a magic symbol.
上级
3bbbaca1
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
32 行增加
和
41 行删除
+32
-41
console.c
console.c
+1
-1
fs.c
fs.c
+5
-6
kalloc.c
kalloc.c
+6
-8
pipe.c
pipe.c
+2
-2
proc.c
proc.c
+4
-10
proc.h
proc.h
+10
-0
syscall.c
syscall.c
+1
-4
sysfile.c
sysfile.c
+1
-6
sysproc.c
sysproc.c
+2
-3
trap.c
trap.c
+0
-1
没有找到文件。
console.c
浏览文件 @
b6095304
...
...
@@ -397,7 +397,7 @@ console_read(int minor, char *dst, int n)
acquire
(
&
kbd_lock
);
while
(
n
>
0
){
while
(
kbd_r
==
kbd_w
){
if
(
c
urproc
[
cpu
()]
->
killed
){
if
(
c
p
->
killed
){
release
(
&
kbd_lock
);
return
-
1
;
}
...
...
fs.c
浏览文件 @
b6095304
...
...
@@ -557,7 +557,6 @@ namei(char *path, int mode, uint *ret_off,
char
**
ret_last
,
struct
inode
**
ret_ip
)
{
struct
inode
*
dp
;
struct
proc
*
cp
=
curproc
[
cpu
()];
char
*
name
;
int
namelen
;
uint
off
,
dev
,
inum
;
...
...
@@ -648,15 +647,15 @@ wdir(struct inode *dp, char *name, uint ino)
panic
(
"wdir write"
);
}
// Create the path
cp
and return its locked inode structure.
// Create the path and return its locked inode structure.
// If cp already exists, return 0.
struct
inode
*
mknod
(
char
*
cp
,
short
type
,
short
major
,
short
minor
)
mknod
(
char
*
path
,
short
type
,
short
major
,
short
minor
)
{
struct
inode
*
ip
,
*
dp
;
char
*
last
;
if
((
dp
=
namei
(
cp
,
NAMEI_CREATE
,
0
,
&
last
,
0
))
==
0
)
if
((
dp
=
namei
(
path
,
NAMEI_CREATE
,
0
,
&
last
,
0
))
==
0
)
return
0
;
ip
=
mknod1
(
dp
,
last
,
type
,
major
,
minor
);
...
...
@@ -691,13 +690,13 @@ mknod1(struct inode *dp, char *name, short type, short major, short minor)
// Unlink the inode named cp.
int
unlink
(
char
*
cp
)
unlink
(
char
*
path
)
{
struct
inode
*
ip
,
*
dp
;
struct
dirent
de
;
uint
off
,
inum
,
dev
;
dp
=
namei
(
cp
,
NAMEI_DELETE
,
&
off
,
0
,
0
);
dp
=
namei
(
path
,
NAMEI_DELETE
,
&
off
,
0
,
0
);
if
(
dp
==
0
)
return
-
1
;
...
...
kalloc.c
浏览文件 @
b6095304
...
...
@@ -40,24 +40,22 @@ kinit(void)
kfree
(
start
,
mem
*
PAGE
);
}
// Free the len bytes of memory pointed at by
cp
,
// Free the len bytes of memory pointed at by
v
,
// which normally should have been returned by a
// call to kalloc(
cp
). (The exception is when
// call to kalloc(
len
). (The exception is when
// initializing the allocator; see kinit above.)
void
kfree
(
char
*
cp
,
int
len
)
kfree
(
char
*
v
,
int
len
)
{
struct
run
**
rr
;
struct
run
*
p
=
(
struct
run
*
)
cp
;
struct
run
*
pend
=
(
struct
run
*
)
(
cp
+
len
);
int
i
;
struct
run
*
p
=
(
struct
run
*
)
v
;
struct
run
*
pend
=
(
struct
run
*
)(
v
+
len
);
if
(
len
%
PAGE
)
panic
(
"kfree"
);
// Fill with junk to catch dangling refs.
for
(
i
=
0
;
i
<
len
;
i
++
)
cp
[
i
]
=
1
;
memset
(
v
,
1
,
len
);
acquire
(
&
kalloc_lock
);
...
...
pipe.c
浏览文件 @
b6095304
...
...
@@ -87,7 +87,7 @@ pipe_write(struct pipe *p, char *addr, int n)
for
(
i
=
0
;
i
<
n
;
i
++
){
while
(((
p
->
writep
+
1
)
%
PIPESIZE
)
==
p
->
readp
){
if
(
p
->
readopen
==
0
||
c
urproc
[
cpu
()]
->
killed
){
if
(
p
->
readopen
==
0
||
c
p
->
killed
){
release
(
&
p
->
lock
);
return
-
1
;
}
...
...
@@ -111,7 +111,7 @@ pipe_read(struct pipe *p, char *addr, int n)
acquire
(
&
p
->
lock
);
while
(
p
->
readp
==
p
->
writep
){
if
(
p
->
writeopen
==
0
||
c
urproc
[
cpu
()]
->
killed
){
if
(
p
->
writeopen
==
0
||
c
p
->
killed
){
release
(
&
p
->
lock
);
return
0
;
}
...
...
proc.c
浏览文件 @
b6095304
...
...
@@ -59,7 +59,6 @@ setupsegs(struct proc *p)
int
growproc
(
int
n
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
char
*
newmem
,
*
oldmem
;
newmem
=
kalloc
(
cp
->
sz
+
n
);
...
...
@@ -183,14 +182,14 @@ scheduler(void)
// before jumping back to us.
setupsegs
(
p
);
c
urproc
[
cpu
()]
=
p
;
c
p
=
p
;
p
->
state
=
RUNNING
;
if
(
setjmp
(
&
cpus
[
cpu
()].
jmpbuf
)
==
0
)
longjmp
(
&
p
->
jmpbuf
);
// Process is done running for now.
// It should have changed its p->state before coming back.
c
urproc
[
cpu
()]
=
0
;
c
p
=
0
;
setupsegs
(
0
);
}
...
...
@@ -204,7 +203,6 @@ scheduler(void)
void
sched
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
cp
->
state
==
RUNNING
)
panic
(
"sched running"
);
...
...
@@ -213,7 +211,7 @@ sched(void)
if
(
cpus
[
cpu
()].
nlock
!=
1
)
panic
(
"sched locks"
);
if
(
setjmp
(
&
p
->
jmpbuf
)
==
0
)
if
(
setjmp
(
&
c
p
->
jmpbuf
)
==
0
)
longjmp
(
&
cpus
[
cpu
()].
jmpbuf
);
}
...
...
@@ -221,7 +219,6 @@ sched(void)
void
yield
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
acquire
(
&
proc_table_lock
);
cp
->
state
=
RUNNABLE
;
...
...
@@ -238,7 +235,7 @@ forkret(void)
release
(
&
proc_table_lock
);
// Jump into assembly, never to return.
forkret1
(
c
urproc
[
cpu
()]
->
tf
);
forkret1
(
c
p
->
tf
);
}
// Atomically release lock and sleep on chan.
...
...
@@ -246,7 +243,6 @@ forkret(void)
void
sleep
(
void
*
chan
,
struct
spinlock
*
lk
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
cp
==
0
)
panic
(
"sleep"
);
...
...
@@ -332,7 +328,6 @@ void
proc_exit
(
void
)
{
struct
proc
*
p
;
struct
proc
*
cp
=
curproc
[
cpu
()];
int
fd
;
if
(
cp
->
pid
==
1
)
...
...
@@ -376,7 +371,6 @@ int
proc_wait
(
void
)
{
struct
proc
*
p
;
struct
proc
*
cp
=
curproc
[
cpu
()];
int
i
,
havekids
,
pid
;
acquire
(
&
proc_table_lock
);
...
...
proc.h
浏览文件 @
b6095304
...
...
@@ -50,7 +50,17 @@ struct proc {
// expandable heap
extern
struct
proc
proc
[];
// If xv6 was only for uniprocessors, this could be
// struct proc *cp;
// Instead we have an array curproc, one per
// processor, and #define cp to the right element
// in the array. In general such preprocessor
// subterfuge is to be avoided, but cp is used
// so often that having the shorthand is worth the ugliness.
extern
struct
proc
*
curproc
[
NCPU
];
// Current (running) process per CPU
#define cp (curproc[cpu()]) // Current process on this CPU
#define MPSTACK 512
...
...
syscall.c
浏览文件 @
b6095304
...
...
@@ -53,7 +53,6 @@ fetchstr(struct proc *p, uint addr, char **pp)
int
argint
(
int
argno
,
int
*
ip
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
return
fetchint
(
cp
,
cp
->
tf
->
esp
+
4
+
4
*
argno
,
ip
);
}
...
...
@@ -65,7 +64,6 @@ int
argptr
(
int
argno
,
char
**
pp
,
int
size
)
{
int
i
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
argint
(
argno
,
&
i
)
<
0
)
return
-
1
;
...
...
@@ -85,7 +83,7 @@ argstr(int argno, char **pp)
int
addr
;
if
(
argint
(
argno
,
&
addr
)
<
0
)
return
-
1
;
return
fetchstr
(
c
urproc
[
cpu
()]
,
addr
,
pp
);
return
fetchstr
(
c
p
,
addr
,
pp
);
}
extern
int
sys_chdir
(
void
);
...
...
@@ -133,7 +131,6 @@ static int (*syscalls[])(void) = {
void
syscall
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
int
num
=
cp
->
tf
->
eax
;
if
(
num
>=
0
&&
num
<
NELEM
(
syscalls
)
&&
syscalls
[
num
])
...
...
sysfile.c
浏览文件 @
b6095304
...
...
@@ -22,7 +22,6 @@ argfd(int argno, int *pfd, struct file **pf)
{
int
fd
;
struct
file
*
f
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
argint
(
argno
,
&
fd
)
<
0
)
return
-
1
;
...
...
@@ -41,7 +40,6 @@ static int
fdalloc
(
struct
file
*
f
)
{
int
fd
;
struct
proc
*
cp
=
curproc
[
cpu
()];
for
(
fd
=
0
;
fd
<
NOFILE
;
fd
++
){
if
(
cp
->
ofile
[
fd
]
==
0
){
...
...
@@ -58,7 +56,6 @@ sys_pipe(void)
int
*
fd
;
struct
file
*
rf
=
0
,
*
wf
=
0
;
int
fd0
,
fd1
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
argptr
(
0
,
(
void
*
)
&
fd
,
2
*
sizeof
fd
[
0
])
<
0
)
return
-
1
;
...
...
@@ -109,7 +106,7 @@ sys_close(void)
if
(
argfd
(
0
,
&
fd
,
&
f
)
<
0
)
return
-
1
;
c
urproc
[
cpu
()]
->
ofile
[
fd
]
=
0
;
c
p
->
ofile
[
fd
]
=
0
;
fileclose
(
f
);
return
0
;
}
...
...
@@ -242,7 +239,6 @@ sys_mkdir(void)
int
sys_chdir
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
struct
inode
*
ip
;
char
*
path
;
...
...
@@ -316,7 +312,6 @@ sys_link(void)
int
sys_exec
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
uint
sz
=
0
,
ap
,
sp
,
p1
,
p2
;
int
i
,
nargs
,
argbytes
,
len
;
struct
inode
*
ip
;
...
...
sysproc.c
浏览文件 @
b6095304
...
...
@@ -20,7 +20,7 @@ sys_fork(void)
{
struct
proc
*
np
;
if
((
np
=
copyproc
(
c
urproc
[
cpu
()]
))
==
0
)
if
((
np
=
copyproc
(
c
p
))
==
0
)
return
-
1
;
np
->
state
=
RUNNABLE
;
return
np
->
pid
;
...
...
@@ -52,7 +52,7 @@ sys_kill(void)
int
sys_getpid
(
void
)
{
return
c
urproc
[
cpu
()]
->
pid
;
return
c
p
->
pid
;
}
int
...
...
@@ -60,7 +60,6 @@ sys_sbrk(void)
{
int
addr
;
int
n
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
argint
(
0
,
&
n
)
<
0
)
return
-
1
;
...
...
trap.c
浏览文件 @
b6095304
...
...
@@ -31,7 +31,6 @@ void
trap
(
struct
trapframe
*
tf
)
{
int
v
=
tf
->
trapno
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
v
==
T_SYSCALL
){
if
(
cp
->
killed
)
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论