Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
02cc595f
提交
02cc595f
8月 22, 2008
创建
作者:
kolya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up circular buffers, so pipe can queue 512 bytes rather than 511
上级
5c5470a2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
14 行删除
+12
-14
console.c
console.c
+7
-7
pipe.c
pipe.c
+5
-7
没有找到文件。
console.c
浏览文件 @
02cc595f
...
...
@@ -186,9 +186,9 @@ console_write(struct inode *ip, char *buf, int n)
struct
{
struct
spinlock
lock
;
char
buf
[
INPUT_BUF
];
int
r
;
// Read index
int
w
;
// Write index
int
e
;
// Edit index
u
int
r
;
// Read index
u
int
w
;
// Write index
u
int
e
;
// Edit index
}
input
;
#define C(x) ((x)-'@') // Control-x
...
...
@@ -205,20 +205,20 @@ console_intr(int (*getc)(void))
procdump
();
break
;
case
C
(
'U'
):
// Kill line.
while
(
input
.
e
>
input
.
w
&&
while
(
input
.
e
!=
input
.
w
&&
input
.
buf
[(
input
.
e
-
1
)
%
INPUT_BUF
]
!=
'\n'
){
input
.
e
--
;
cons_putc
(
BACKSPACE
);
}
break
;
case
C
(
'H'
):
// Backspace
if
(
input
.
e
>
input
.
w
){
if
(
input
.
e
!=
input
.
w
){
input
.
e
--
;
cons_putc
(
BACKSPACE
);
}
break
;
default:
if
(
c
!=
0
&&
input
.
e
<
input
.
r
+
INPUT_BUF
){
if
(
c
!=
0
&&
input
.
e
-
input
.
r
<
INPUT_BUF
){
input
.
buf
[
input
.
e
++
%
INPUT_BUF
]
=
c
;
cons_putc
(
c
);
if
(
c
==
'\n'
||
c
==
C
(
'D'
)
||
input
.
e
==
input
.
r
+
INPUT_BUF
){
...
...
@@ -293,7 +293,7 @@ panic(char *s)
__asm
__volatile
(
"cli"
);
use_console_lock
=
0
;
cprintf
(
"cpu%d: panic: "
,
cpu
());
cprintf
(
s
,
0
);
cprintf
(
s
);
cprintf
(
"
\n
"
);
getcallerpcs
(
&
s
,
pcs
);
for
(
i
=
0
;
i
<
10
;
i
++
)
...
...
pipe.c
浏览文件 @
02cc595f
...
...
@@ -11,8 +11,8 @@
struct
pipe
{
int
readopen
;
// read fd is still open
int
writeopen
;
// write fd is still open
int
writep
;
// next index to write
int
readp
;
// next index to read
uint
writep
;
// next index to write
uint
readp
;
// next index to read
struct
spinlock
lock
;
char
data
[
PIPESIZE
];
};
...
...
@@ -83,7 +83,7 @@ pipewrite(struct pipe *p, char *addr, int n)
acquire
(
&
p
->
lock
);
for
(
i
=
0
;
i
<
n
;
i
++
){
while
(
((
p
->
writep
+
1
)
%
PIPESIZE
)
==
p
->
readp
)
{
while
(
p
->
writep
==
p
->
readp
+
PIPESIZE
)
{
if
(
p
->
readopen
==
0
||
cp
->
killed
){
release
(
&
p
->
lock
);
return
-
1
;
...
...
@@ -91,8 +91,7 @@ pipewrite(struct pipe *p, char *addr, int n)
wakeup
(
&
p
->
readp
);
sleep
(
&
p
->
writep
,
&
p
->
lock
);
}
p
->
data
[
p
->
writep
]
=
addr
[
i
];
p
->
writep
=
(
p
->
writep
+
1
)
%
PIPESIZE
;
p
->
data
[
p
->
writep
++
%
PIPESIZE
]
=
addr
[
i
];
}
wakeup
(
&
p
->
readp
);
release
(
&
p
->
lock
);
...
...
@@ -115,8 +114,7 @@ piperead(struct pipe *p, char *addr, int n)
for
(
i
=
0
;
i
<
n
;
i
++
){
if
(
p
->
readp
==
p
->
writep
)
break
;
addr
[
i
]
=
p
->
data
[
p
->
readp
];
p
->
readp
=
(
p
->
readp
+
1
)
%
PIPESIZE
;
addr
[
i
]
=
p
->
data
[
p
->
readp
++
%
PIPESIZE
];
}
wakeup
(
&
p
->
writep
);
release
(
&
p
->
lock
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论