OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 6:23 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Disk IO and OS
PostPosted: Wed Sep 12, 2007 1:45 am 
Offline

Joined: Wed Sep 12, 2007 1:37 am
Posts: 2
we know that the disk read or write couple of fix size (say 64k).
what if i got an io smaller than 64k for example 30k. what will the os do?
Does the os need to read the 64k from the disk first then write the update 64k to the disk?
help me.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 12, 2007 1:48 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.

Cheers,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 12, 2007 2:39 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 07, 2007 1:45 pm
Posts: 1401
Location: Eugene, OR, US
The blocks cached by the OS do not *need* to be the same size as the clusters on your disk. They can be smaller. But it makes things a bit more complicated if they are different sizes. My OS reads and writes in 32K chunks, for any cluster size larger than 32K.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 1:32 am 
Offline

Joined: Wed Sep 12, 2007 1:37 am
Posts: 2
AJ wrote:
Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.

Cheers,
Adam


Thank you
then what is the default io size for a disk. Can I change it?
for example i got an aplication io size 30k. i want to change the disk io size to 32k making it more efficient.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 5:16 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7614
Location: Germany
I am not sure I understood your question correctly, but you might want to check out the C standard functions setvbuf() (in <stdio.h>).

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 7:53 pm 
Offline
Member
Member

Joined: Sat Dec 30, 2006 2:31 pm
Posts: 729
Location: East Coast, USA
dillonhao wrote:
AJ wrote:
Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.

Cheers,
Adam


Thank you
then what is the default io size for a disk. Can I change it?
for example i got an aplication io size 30k. i want to change the disk io size to 32k making it more efficient.


Disks, such as hard drives and floppy drives, work in blocks of 512 bytes(normally, of course their are exceptions.) CDs work in blocks on 2048 blocks IIRC. The OS however could have larger block sizes of say 4096 bytes. Also some filesystems have bigger blocks such as 4096 or higher.

_________________
My OS: Fuzzy Logic


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 59 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group