Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BufferCache readAsync

1 view
Skip to first unread message

Mohnish Rao

unread,
Apr 30, 2005, 11:05:48 PM4/30/05
to
So basically, BufferCache's readAsync does exactly the same thing as
readSync, except if the page is not in the cache, it returns null? The
caller is expected to get the page from the OSEvent in that case?


Yiu Fai Sit

unread,
May 2, 2005, 3:29:34 AM5/2/05
to

yes to both questions.

Sit

Mohnish Rao

unread,
May 3, 2005, 11:03:44 PM5/3/05
to
Do we need to include the page in the OSEvent even if it is in the cache? I
don't see how we can access the page otherwise. For ex. readBlockReq in VFS,
calls readAsync, checks if the returned page is null or not and returns true
or false. It doesn't store the page anywhere.

"Yiu Fai Sit" <yf...@cs.utexas.edu> wrote in message
news:d54koa$j60$1...@news.cs.utexas.edu...

Yiu Fai Sit

unread,
May 4, 2005, 9:02:03 PM5/4/05
to
There is a method called lookup() for that purpose in your example.

Sit

Mohnish Rao

unread,
May 5, 2005, 1:06:38 PM5/5/05
to Yiu Fai Sit
The lookup method in BufferCache is private.

Rizky Djong

unread,
May 5, 2005, 6:47:25 PM5/5/05
to Mohnish Rao, Yiu Fai Sit
Since initially the first four default blocks are not in the
memory, shouldn't we then still need to read those values from the disk
first instead of returning null?

Otherwise an error would be thrown when bufferCache tries to set the pin
for those four blocks.

Powei Feng

unread,
May 6, 2005, 2:22:53 AM5/6/05
to
But where does "MemPage" get put into the OSEvent? I searched the
code but found no place where this happens. Do we even need to
worry about it?

Thanks,

Powei Feng

Yiu Fai Sit

unread,
May 6, 2005, 12:14:21 PM5/6/05
to
you can still use it in a BufferCache method, like in readAsync() of
BufferCache, and I don't think you should call VFS.readAsync in
VFS.readBlockReq.

Sit

Yiu Fai Sit

unread,
May 6, 2005, 12:25:06 PM5/6/05
to
Please read the given VFS.start(). It is done in this method.

Sit

Mohnish Rao

unread,
May 7, 2005, 9:31:44 PM5/7/05
to
readBlockReq is one of the methods given to us.

private boolean readBlockReq( int devNum, int block, OSEvent ev )
{
Dbg.ASSERT( !sync );

MemPage page = this.bufferCache.readAsync( devNum, block, ev );

if ( page != null )
return true;
else
return false;
}

I'm still confused about how we get access to a page if it IS in the cache.
readAsync() returns the page. But readBlockReq doesn't store it anywhere. If
the page was NOT in the cache, readAsync would store it in OSEvent.

"Yiu Fai Sit" <yf...@cs.utexas.edu> wrote in message

news:d5g4v3$qs2$1...@news.cs.utexas.edu...

Mohnish Rao

unread,
May 8, 2005, 12:50:49 AM5/8/05
to
And when I say readAsync, I mean BufferCache.readAsync not VFS.readAsync.
Sorry about that confusion.

"Mohnish Rao" <mohni...@hotmail.com> wrote in message
news:d5jpuo$7bu$1...@news.cs.utexas.edu...

Yiu Fai Sit

unread,
May 8, 2005, 1:22:24 AM5/8/05
to
Oh, I misinterpreted your question. Yes, you should put the page in the
event. sorry about that.

Sit

Sidd

unread,
May 9, 2005, 2:32:22 PM5/9/05
to
In buffercache readasync, if the page is not in the cache, we get it from
disk and then return null null right? If so, the blockdriver calls the disk
which schedules a callback. But what we get from the ev is just a new
MemPage with no data in it. So the problem we have is when we try to create
a new file, we try to see how many blocks the superblock allows for and we
get 0 as the whole superblock (as fetched from the buffercache) is all
zeroes. We're assuming this is because the callback has not been scheduled
yet. How do we get around this?

Thanks,
Sidd.


"Yiu Fai Sit" <yf...@cs.utexas.edu> wrote in message

news:d54koa$j60$1...@news.cs.utexas.edu...

Adrian Kubala

unread,
May 9, 2005, 3:07:27 PM5/9/05
to
Sidd <siddhar...@hotmail.com> schrieb:
> The whole superblock (as fetched from the buffercache) is all zeroes.

> We're assuming this is because the callback has not been scheduled
> yet. How do we get around this?

When you request the block to be swapped in, you mark the page as
io_pending, right? So if a process tries to read from an io_pending page
you need to block it until the page is done swapping in.

Phong Q. Pho

unread,
May 9, 2005, 4:35:55 PM5/9/05
to Adrian Kubala
So I'm still confused about blocking, I presume that you block the process
inside BC.readASync(), if the page you're trying to read is io_pending.
My question is, how will it be unblocked? and how will it know to pick up
right where it left off and read the desired page?

Phong

Chris Bandy

unread,
May 9, 2005, 7:25:11 PM5/9/05
to
You don't block the process in BufferCache.

BC.readAsync returns a null if there was a cache miss. VFS needs to
block the process when this happens. Since the event you passed to BC
contains the SYSCALL type, BD will enqueue an interrupt when it reads.
OS will examine this interrupt after the appropriate delay and call the
callback for the SYSCALL type. The callback should unblock the process.

Compare readAsync and writeCallback to understand how they did the blocking.


-- Chris

Rizky Djong

unread,
May 10, 2005, 8:41:15 AM5/10/05
to
I keep on getting an outOfMemoryError when trying to put the page into the
OSEvent on a cache hit.

After isolating the problem, I found that the error is thrown by this line
of code:
ev.put("MemPage", page);

Can someone point me some possible reasons for it?

Thanks in advance

Rizky Djong

unread,
May 10, 2005, 9:28:25 AM5/10/05
to
Actually, please ignore my previous debugging question. I've just found
out that the error is caused by some other reason. I was too much in a
hurry to ask it in the newsgroup since it's going to be due soon.
0 new messages