Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
02cc595f
Commit
02cc595f
authored
16 years ago
by
kolya
Browse files
Options
Downloads
Patches
Plain Diff
clean up circular buffers, so pipe can queue 512 bytes rather than 511
parent
5c5470a2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
console.c
+7
-7
7 additions, 7 deletions
console.c
pipe.c
+5
-7
5 additions, 7 deletions
pipe.c
with
12 additions
and
14 deletions
console.c
+
7
−
7
View file @
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
++
)
...
...
This diff is collapsed.
Click to expand it.
pipe.c
+
5
−
7
View file @
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
u
int
writep
;
// next index to write
u
int
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment