ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
algorithm:breada
input:file system block number for immediate read
file system block number for asynchronous read
output:buffer containing data for immediate read
{
if(first block not in cache)
{
get buffer for first block
if(buffer data not valid)
initiate disk read
}
if(second block not in cache)
{
get buffer for second block)
if(buffer data valid) //line 1
release buffer
else
initiate disk read //line 2
}
if(first block was originally in cache) //line 3
{
read first block
return buffer
}
sleep(event first buffer contains valid data)
return buffer
}
here is an algorithm for block read algorithm. i have problem in
line 1: if buffer data is valid why is it releasing the buffer?
line 2: if buffer data valid why is it initiating disk read. it should have read directly from buffer?
line 3:it should be the first condition as if it is there in cache then it should return it without delay?
so please clear my doubts in these statements.....
algorithm:breada
input:file system block number for immediate read
file system block number for asynchronous read
output:buffer containing data for immediate read
{
if(first block not in cache)
{
get buffer for first block
if(buffer data not valid)
initiate disk read
}
if(second block not in cache)
{
get buffer for second block)
if(buffer data valid) //line 1
release buffer
else
initiate disk read //line 2
}
if(first block was originally in cache) //line 3
{
read first block
return buffer
}
sleep(event first buffer contains valid data)
return buffer
}
here is an algorithm for block read algorithm. i have problem in
line 1: if buffer data is valid why is it releasing the buffer?
line 2: if buffer data valid why is it initiating disk read. it should have read directly from buffer?
line 3:it should be the first condition as if it is there in cache then it should return it without delay?
so please clear my doubts in these statements.....
Please copy-paste screen output of
Code:
cat -n your_file.c
Please use code tags - for that go to "Advance" menu, select your with mouse and press '#' button.
i read this algorithm from the same book but still i have some issues after reading it (as i already posted in my first post).....so please clarify those doubts....
Location: Bangalore ,Karnataka, India, Asia, Earth, Solar system, milky way galaxy, black hole
Distribution: murugesan openssl
Posts: 181
Rep:
Quote:
Originally Posted by harit agarwal
line 1: if buffer data is valid why is it releasing the buffer?
This requires information to read on "brelse" algorithm (provided you have gone through 5 steps mentioned in "the kernel may follow in getblk".)
Quote:
Originally Posted by harit agarwal
line 2: if buffer data valid why is it initiating disk read. it should have read directly from buffer?
Kernel will go to initiate disk read when the buffer data is invalid.
Quote:
Originally Posted by harit agarwal
line 3:it should be the first condition as if it is there in cache then it should return it without delay?
This is because the following statement is given in the book:
"If the second block is not in the buffer cache, the kernel instructs the disk driver to read it ASYNCHRONOUSLY."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.