[comp.sys.amiga] More dos questions

rogers@iris.ucdavis.edu (Brewski Rogers) (10/13/89)

Hi, I'd like to thank everyone who responded to my earlier question on
speeding up file reading. Now I have a few more:

1.	How exactly is Seek() implemented? If I Seek 200K forward, will dos
read through all the data until it gets there, or does it have some way of 
figuring out where to move the head to? If it does have a way of knowing
where to move the head to, is the information easily found, or does it
have to move the head to find it?

2.	What are the effects of Read()ing small chunks? (say 2-6K) will
AddBuffers speed things like this up? (assuming more than one chunk is
on the same track.)

3.	Are there any disk optimizers that will write a file so it can
be read with maximum efficiency? I know BAD optimizes for directory
scanning or info files, but that's not what I need. (maybe I could
rename my big data file to .info and BAD would optimize it? :-)

helpful replies are eagerly awaited!

------------------------------------------------------          Quantum _\/_
2727 Eel                   Bruce (6502 RULES!) Rogers        |\  Duck  ( 0 0)
Davis, Ca 95616            Quantum Duck Software,           |\ \______/ / \\\
916-756-2684               rogers@iris.ucdavis.edu         |\ <  <     |   \/
"It's better to be the real thing than the right thing."     \________/  Quark!

daveh@cbmvax.UUCP (Dave Haynie) (10/13/89)

in article <5599@ucdavis.ucdavis.edu>, rogers@iris.ucdavis.edu (Brewski Rogers) says:
> Keywords: dos,sod,dso,osd
> Xref: cbmvax comp.sys.amiga.tech:8243 comp.sys.amiga:44101

> 1.	How exactly is Seek() implemented? If I Seek 200K forward, will dos
> read through all the data until it gets there, or does it have some way of 
> figuring out where to move the head to? If it does have a way of knowing
> where to move the head to, is the information easily found, or does it
> have to move the head to find it?

Each file header contains pointers to the first 72 data blocks.  If a file
is longer than that, the file header will have a pointer to an extension 
block, which points to the next 72 data blocks, and also has an extension
block.  So to seek ahead 200K, the filesystem will have to move through 
5 extension blocks to find the pointer that references the block at 200K.

> 2727 Eel                   Bruce (6502 RULES!) Rogers        |\  Duck  ( 0 0)
-- 
Dave Haynie Commodore-Amiga (Systems Engineering) "The Crew That Never Rests"
   {uunet|pyramid|rutgers}!cbmvax!daveh      PLINK: hazy     BIX: hazy
                    Too much of everything is just enough

ccplumb@rose.waterloo.edu (Colin Plumb) (10/14/89)

In article <5599@ucdavis.ucdavis.edu> rogers@iris.ucdavis.edu (Brewski Rogers)
writes:

>1.	How exactly is Seek() implemented? If I Seek 200K forward, will dos
>read through all the data until it gets there, or does it have some way of 
>figuring out where to move the head to? If it does have a way of knowing
>where to move the head to, is the information easily found, or does it
>have to move the head to find it?

In the current FS's, a file header block contains pointers to the first 72
data blocks in a file, and a pointer to an extension block, which holds
another 72 pointers and another next pointer.  So you have to follow
the chain of extension blocks until you find the correct one, then you
have all the pointers at your disposal.  If you Seek() forward, you can
start from the "current" extension block, but if you go backwards, you
have to go back to the start and scan forwards again.
-- 
	-Colin

rogers@iris.ucdavis.edu (Brewski Rogers) (10/14/89)

In article <8181@cbmvax.UUCP> daveh@cbmvax.UUCP (Dave Haynie) writes:
>Each file header contains pointers to the first 72 data blocks.  If a file
>is longer than that, the file header will have a pointer to an extension 
>block, which points to the next 72 data blocks, and also has an extension
>block.  So to seek ahead 200K, the filesystem will have to move through 
>5 extension blocks to find the pointer that references the block at 200K.
>
>Dave Haynie Commodore-Amiga (Systems Engineering) "The Crew That Never Rests"


So is there some way I can get dos to buffer the data in the extension
blocks? Or failing that, put them on (or near) the same track that
they reference? Where does AmigaDos tend to put them now?

Thanks a bunch!

------------------------------------------------------          Quantum _\/_
2727 Eel                   Bruce (6502 RULES!) Rogers        |\  Duck  ( 0 0)
Davis, Ca 95616            Quantum Duck Software,           |\ \______/ / \\\
916-756-2684               rogers@iris.ucdavis.edu         |\ <  <     |   \/
"It's better to be the real thing than the right thing."     \________/  Quark!

thomas@rimfaxe.diku.dk (Thomas Nikolajsen) (11/03/89)

daveh@cbmvax.UUCP (Dave Haynie) writes:

>in article <5599@ucdavis.ucdavis.edu>, rogers@iris.ucdavis.edu (Brewski Rogers) says:
>> Keywords: dos,sod,dso,osd
>> Xref: cbmvax comp.sys.amiga.tech:8243 comp.sys.amiga:44101

>> 1.	How exactly is Seek() implemented? If I Seek 200K forward, will dos
>> read through all the data until it gets there, or does it have some way of 
>> figuring out where to move the head to? If it does have a way of knowing
>> where to move the head to, is the information easily found, or does it
>> have to move the head to find it?

>Each file header contains pointers to the first 72 data blocks.  If a file
>is longer than that, the file header will have a pointer to an extension 
>block, which points to the next 72 data blocks, and also has an extension
>block.  So to seek ahead 200K, the filesystem will have to move through 
>5 extension blocks to find the pointer that references the block at 200K.

This answer indicates that:
  (X) all data blocks in a file, but the last, shall have the same length.
Especially this shall be the case for OSF (the old file system), but there
each data block does have a long word containing the length of the data in the
block, this seems quite stupid if it is only really used in the last one. If it
is only for the redundancy with the total number of bytes in the files, stored
in the file header block, then it seems to be a waisted long word per data
block, it could be done cheaper.

I don't remember to have seen the (X) requirement in the "Amigados
Technical Reference Manual" for v1.2 (or what the title of the "technical"
part of this Amigados manual from Bantam Books is). As I don't have the
manual here to check it out,  I could be entirely wrong.
Off cause the (X) requirement should be granted to make it possible to
implement Seek() in an efficient way.

Thomas Nikolajsen, thomas@freja.diku.dk "don't say it makes any sense, it doesn't"
Computer Science Department, Copenhagen University, Denmark, here, somewhere