Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
9fee0d5f
提交
9fee0d5f
5月 07, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
queue of children
more condition vars queue.h
上级
b025a666
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
57 行增加
和
46 行删除
+57
-46
condvar.c
condvar.c
+2
-1
console.c
console.c
+1
-0
exec.c
exec.c
+1
-0
file.c
file.c
+2
-1
file.h
file.h
+1
-0
fs.c
fs.c
+8
-3
ide.c
ide.c
+1
-0
kalloc.c
kalloc.c
+1
-0
main.c
main.c
+1
-0
mp.c
mp.c
+1
-0
pipe.c
pipe.c
+1
-0
proc.c
proc.c
+24
-35
proc.h
proc.h
+4
-4
spinlock.c
spinlock.c
+1
-0
syscall.c
syscall.c
+1
-0
sysfile.c
sysfile.c
+1
-0
sysproc.c
sysproc.c
+1
-0
trap.c
trap.c
+1
-0
uart.c
uart.c
+3
-2
vm.c
vm.c
+1
-0
没有找到文件。
condvar.c
浏览文件 @
9fee0d5f
...
...
@@ -5,6 +5,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
void
...
...
@@ -19,7 +20,7 @@ cv_sleep(struct condvar *cv, struct spinlock *lk)
// Must acquire cv_lock to avoid sleep/wakeup race
acquire
(
&
cv
->
lock
);
cprintf
(
"cv_sleep: 0x%x
\n
"
,
cv
);
cprintf
(
"cv_sleep: 0x%x
%s
\n
"
,
cv
,
cv
->
lock
.
name
);
release
(
lk
);
...
...
console.c
浏览文件 @
9fee0d5f
...
...
@@ -11,6 +11,7 @@
#include "fs.h"
#include "file.h"
#include "mmu.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
...
...
exec.c
浏览文件 @
9fee0d5f
...
...
@@ -3,6 +3,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "defs.h"
#include "x86.h"
...
...
file.c
浏览文件 @
9fee0d5f
#include "types.h"
#include "defs.h"
#include "param.h"
#include "spinlock.h"
#include "condvar.h"
#include "fs.h"
#include "file.h"
#include "spinlock.h"
struct
devsw
devsw
[
NDEV
];
struct
{
...
...
file.h
浏览文件 @
9fee0d5f
...
...
@@ -16,6 +16,7 @@ struct inode {
uint
inum
;
// Inode number
int
ref
;
// Reference count
int
flags
;
// I_BUSY, I_VALID
struct
condvar
cv
;
short
type
;
// copy of disk inode
short
major
;
...
...
fs.c
浏览文件 @
9fee0d5f
...
...
@@ -17,6 +17,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "buf.h"
#include "fs.h"
...
...
@@ -138,7 +139,11 @@ struct {
void
iinit
(
void
)
{
int
i
;
initlock
(
&
icache
.
lock
,
"icache"
);
for
(
i
=
0
;
i
<
NINODE
;
i
++
)
{
initlock
(
&
icache
.
inode
[
i
].
cv
.
lock
,
"icache"
);
}
}
static
struct
inode
*
iget
(
uint
dev
,
uint
inum
);
...
...
@@ -246,7 +251,7 @@ ilock(struct inode *ip)
acquire
(
&
icache
.
lock
);
while
(
ip
->
flags
&
I_BUSY
)
sleep
(
ip
,
&
icache
.
lock
);
cv_sleep
(
&
ip
->
cv
,
&
icache
.
lock
);
ip
->
flags
|=
I_BUSY
;
release
(
&
icache
.
lock
);
...
...
@@ -275,7 +280,7 @@ iunlock(struct inode *ip)
acquire
(
&
icache
.
lock
);
ip
->
flags
&=
~
I_BUSY
;
wakeup
(
ip
);
cv_wakeup
(
&
ip
->
cv
);
release
(
&
icache
.
lock
);
}
...
...
@@ -295,7 +300,7 @@ iput(struct inode *ip)
iupdate
(
ip
);
acquire
(
&
icache
.
lock
);
ip
->
flags
=
0
;
wakeup
(
ip
);
cv_wakeup
(
&
ip
->
cv
);
}
ip
->
ref
--
;
release
(
&
icache
.
lock
);
...
...
ide.c
浏览文件 @
9fee0d5f
...
...
@@ -6,6 +6,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
#include "traps.h"
...
...
kalloc.c
浏览文件 @
9fee0d5f
...
...
@@ -8,6 +8,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "kalloc.h"
...
...
main.c
浏览文件 @
9fee0d5f
...
...
@@ -4,6 +4,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
...
...
mp.c
浏览文件 @
9fee0d5f
...
...
@@ -10,6 +10,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
struct
cpu
cpus
[
NCPU
];
...
...
pipe.c
浏览文件 @
9fee0d5f
...
...
@@ -4,6 +4,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "fs.h"
#include "file.h"
...
...
proc.c
浏览文件 @
9fee0d5f
...
...
@@ -5,6 +5,7 @@
#include "x86.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
struct
ptable
ptables
[
NCPU
];
...
...
@@ -91,7 +92,7 @@ addrun1(struct runq *rq, struct proc *p)
{
struct
proc
*
q
;
cprintf
(
"%d: add to run %d
\n
"
,
cpu
->
id
,
p
->
pid
);
for
(
q
=
rq
->
runq
;
q
!=
0
;
q
=
q
->
runq
)
{
SLIST_FOREACH
(
q
,
&
rq
->
runq
,
run_next
)
{
if
(
q
==
p
)
{
cprintf
(
"allready on q
\n
"
);
p
->
state
=
RUNNABLE
;
...
...
@@ -99,8 +100,7 @@ addrun1(struct runq *rq, struct proc *p)
}
}
p
->
state
=
RUNNABLE
;
// race?
p
->
runq
=
rq
->
runq
;
rq
->
runq
=
p
;
SLIST_INSERT_HEAD
(
&
rq
->
runq
,
p
,
run_next
);
}
void
...
...
@@ -113,23 +113,13 @@ addrun(struct proc *p)
}
static
void
delrun1
(
struct
runq
*
rq
,
struct
proc
*
p
roc
)
delrun1
(
struct
runq
*
rq
,
struct
proc
*
p
)
{
struct
proc
*
p
=
0
;
struct
proc
*
n
;
n
=
rq
->
runq
;
while
(
n
!=
0
)
{
if
(
n
==
proc
)
{
if
(
p
==
0
)
{
rq
->
runq
=
n
->
runq
;
}
else
{
p
->
runq
=
n
->
runq
;
}
n
->
runq
=
0
;
struct
proc
*
q
,
*
nq
;
SLIST_FOREACH_SAFE
(
q
,
&
rq
->
runq
,
run_next
,
nq
)
{
if
(
q
==
p
)
{
SLIST_REMOVE
(
&
rq
->
runq
,
q
,
proc
,
run_next
);
return
;
}
else
{
p
=
n
;
n
=
n
->
runq
;
}
}
}
...
...
@@ -224,10 +214,12 @@ fork(void)
if
(
proc
->
ofile
[
i
])
np
->
ofile
[
i
]
=
filedup
(
proc
->
ofile
[
i
]);
np
->
cwd
=
idup
(
proc
->
cwd
);
SLIST_INSERT_HEAD
(
&
proc
->
childq
,
np
,
child_next
);
// XXX lock?
pid
=
np
->
pid
;
addrun
(
np
);
safestrcpy
(
np
->
name
,
proc
->
name
,
sizeof
(
proc
->
name
));
return
pid
;
}
...
...
@@ -293,22 +285,21 @@ exit(void)
int
wait
(
void
)
{
struct
proc
*
p
;
struct
proc
*
p
,
*
np
;
int
havekids
,
pid
;
int
c
;
cprintf
(
"wait %d
\n
"
,
proc
->
pid
);
for
(;;){
// Scan through table looking for zombie children.
havekids
=
0
;
for
(
c
=
0
;
c
<
NCPU
;
c
++
)
{
acquire
(
&
ptables
[
c
].
lock
);
// XXX Unscalable
for
(
p
=
ptables
[
c
].
proc
;
p
<
&
ptables
[
c
].
proc
[
NPROC
];
p
++
){
if
(
p
->
parent
!=
proc
)
continue
;
acquire
(
&
proc
->
lock
);
SLIST_FOREACH_SAFE
(
p
,
&
proc
->
childq
,
child_next
,
np
)
{
havekids
=
1
;
acquire
(
&
p
->
lock
);
if
(
p
->
state
==
ZOMBIE
){
// Found one.
pid
=
p
->
pid
;
SLIST_REMOVE
(
&
proc
->
childq
,
p
,
proc
,
child_next
);
kfree
(
p
->
kstack
);
p
->
kstack
=
0
;
freevm
(
p
->
pgdir
);
...
...
@@ -317,15 +308,13 @@ wait(void)
p
->
parent
=
0
;
p
->
name
[
0
]
=
0
;
p
->
killed
=
0
;
release
(
&
ptables
[
c
].
lock
);
release
(
&
p
->
lock
);
release
(
&
proc
->
lock
);
return
pid
;
}
}
release
(
&
ptables
[
c
].
lock
);
release
(
&
p
->
lock
);
}
acquire
(
&
proc
->
lock
);
// No point waiting if we don't have any children.
if
(
!
havekids
||
proc
->
killed
){
release
(
&
proc
->
lock
);
...
...
@@ -350,7 +339,7 @@ steal(void)
if
(
c
==
cpunum
())
continue
;
acquire
(
&
runqs
[
c
].
lock
);
for
(
p
=
runqs
[
c
].
runq
;
p
!=
0
;
p
=
p
->
runq
)
{
SLIST_FOREACH
(
p
,
&
runqs
[
c
].
runq
,
run_next
)
{
if
(
p
->
state
==
RUNNABLE
)
{
cprintf
(
"%d: steal %d from %d
\n
"
,
cpunum
(),
p
->
pid
,
c
);
delrun1
(
&
runqs
[
c
],
p
);
...
...
@@ -386,7 +375,7 @@ scheduler(void)
// Loop over process table looking for process to run.
acquire
(
&
runq
->
lock
);
for
(
p
=
runq
->
runq
;
p
!=
0
;
p
=
p
->
runq
)
{
SLIST_FOREACH
(
p
,
&
runq
->
runq
,
run_next
)
{
if
(
p
->
state
!=
RUNNABLE
)
continue
;
...
...
@@ -544,7 +533,7 @@ procdump(int c)
cprintf
(
"
\n
"
);
}
cprintf
(
"runq: "
);
for
(
q
=
runqs
[
c
].
runq
;
q
!=
0
;
q
=
q
->
runq
)
{
SLIST_FOREACH
(
q
,
&
runqs
[
c
].
runq
,
run_next
)
{
if
(
q
->
state
>=
0
&&
q
->
state
<
NELEM
(
states
)
&&
states
[
q
->
state
])
state
=
states
[
q
->
state
];
else
...
...
proc.h
浏览文件 @
9fee0d5f
...
...
@@ -46,8 +46,9 @@ struct proc {
struct
inode
*
cwd
;
// Current directory
char
name
[
16
];
// Process name (debugging)
struct
spinlock
lock
;
struct
proc
*
runq
;
struct
proc
*
childq
;
SLIST_ENTRY
(
proc
)
run_next
;
SLIST_HEAD
(
childlist
,
proc
)
childq
;
SLIST_ENTRY
(
proc
)
child_next
;
struct
condvar
cv
;
};
...
...
@@ -75,11 +76,10 @@ struct cpu {
struct
runq
*
runq
;
// The per-core proc table
};
struct
runq
{
char
name
[
MAXNAME
];
struct
spinlock
lock
;
struct
proc
*
runq
;
SLIST_HEAD
(
runlist
,
proc
)
runq
;
};
struct
ptable
{
...
...
spinlock.c
浏览文件 @
9fee0d5f
...
...
@@ -7,6 +7,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
void
...
...
syscall.c
浏览文件 @
9fee0d5f
...
...
@@ -4,6 +4,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
#include "syscall.h"
...
...
sysfile.c
浏览文件 @
9fee0d5f
...
...
@@ -5,6 +5,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "fs.h"
#include "file.h"
...
...
sysproc.c
浏览文件 @
9fee0d5f
...
...
@@ -5,6 +5,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
int
...
...
trap.c
浏览文件 @
9fee0d5f
...
...
@@ -4,6 +4,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
#include "traps.h"
...
...
uart.c
浏览文件 @
9fee0d5f
...
...
@@ -5,12 +5,13 @@
#include "param.h"
#include "traps.h"
#include "spinlock.h"
#include "fs.h"
#include "file.h"
#include "mmu.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "x86.h"
#include "fs.h"
#include "file.h"
#define COM1 0x3f8
...
...
vm.c
浏览文件 @
9fee0d5f
...
...
@@ -5,6 +5,7 @@
#include "mmu.h"
#include "spinlock.h"
#include "condvar.h"
#include "queue.h"
#include "proc.h"
#include "elf.h"
#include "kalloc.h"
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论