Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
14938f93
Commit
14938f93
authored
18 years ago
by
rtm
Browse files
Options
Downloads
Patches
Plain Diff
buffer cache, fifo replacement
parent
7ce01cf9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Notes
+3
-0
3 additions, 0 deletions
Notes
bio.c
+19
-4
19 additions, 4 deletions
bio.c
buf.h
+1
-0
1 addition, 0 deletions
buf.h
usertests.c
+1
-1
1 addition, 1 deletion
usertests.c
with
24 additions
and
5 deletions
Notes
+
3
−
0
View file @
14938f93
...
...
@@ -354,3 +354,6 @@ HMM maybe the variables at the end of struct cpu are being overwritten
OH! recursive interrupts will use up any amount of cpu[].stack!
underflow and wrecks *previous* cpu's struct
better buffer cache replacement
read/write of open file that's been unlinked
This diff is collapsed.
Click to expand it.
bio.c
+
19
−
4
View file @
14938f93
...
...
@@ -20,20 +20,31 @@ struct buf *
getblk
(
uint
dev
,
uint
sector
)
{
struct
buf
*
b
;
static
struct
buf
*
scan
=
buf
;
int
i
;
acquire
(
&
buf_table_lock
);
while
(
1
){
for
(
b
=
buf
;
b
<
buf
+
NBUF
;
b
++
)
if
((
b
->
flags
&
B_BUSY
)
&&
b
->
dev
==
dev
&&
b
->
sector
)
if
((
b
->
flags
&
(
B_BUSY
|
B_VALID
)
)
&&
b
->
dev
==
dev
&&
b
->
sector
==
sector
)
break
;
if
(
b
<
buf
+
NBUF
){
sleep
(
buf
,
&
buf_table_lock
);
if
(
b
->
flags
&
B_BUSY
){
sleep
(
buf
,
&
buf_table_lock
);
}
else
{
b
->
flags
|=
B_BUSY
;
release
(
&
buf_table_lock
);
return
b
;
}
}
else
{
for
(
b
=
buf
;
b
<
buf
+
NBUF
;
b
++
){
for
(
i
=
0
;
i
<
NBUF
;
i
++
){
b
=
scan
++
;
if
(
scan
>=
buf
+
NBUF
)
scan
=
buf
;
if
((
b
->
flags
&
B_BUSY
)
==
0
){
b
->
flags
|
=
B_BUSY
;
b
->
flags
=
B_BUSY
;
b
->
dev
=
dev
;
b
->
sector
=
sector
;
release
(
&
buf_table_lock
);
...
...
@@ -53,11 +64,14 @@ bread(uint dev, uint sector)
extern
struct
spinlock
ide_lock
;
b
=
getblk
(
dev
,
sector
);
if
(
b
->
flags
&
B_VALID
)
return
b
;
acquire
(
&
ide_lock
);
c
=
ide_start_rw
(
dev
&
0xff
,
sector
,
b
->
data
,
1
,
1
);
sleep
(
c
,
&
ide_lock
);
ide_finish
(
c
);
b
->
flags
|=
B_VALID
;
release
(
&
ide_lock
);
return
b
;
...
...
@@ -73,6 +87,7 @@ bwrite(uint dev, struct buf *b, uint sector)
c
=
ide_start_rw
(
dev
&
0xff
,
sector
,
b
->
data
,
1
,
0
);
sleep
(
c
,
&
ide_lock
);
ide_finish
(
c
);
b
->
flags
|=
B_VALID
;
release
(
&
ide_lock
);
}
...
...
This diff is collapsed.
Click to expand it.
buf.h
+
1
−
0
View file @
14938f93
...
...
@@ -5,3 +5,4 @@ struct buf {
uchar
data
[
512
];
};
#define B_BUSY 0x1
#define B_VALID 0x2
This diff is collapsed.
Click to expand it.
usertests.c
+
1
−
1
View file @
14938f93
...
...
@@ -339,7 +339,7 @@ main(int argc, char *argv[])
{
puts
(
"usertests starting
\n
"
);
unlinkread
();
//
unlinkread();
createdelete
();
twofiles
();
sharedfd
();
...
...
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