home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.arch
- Path: sparky!uunet!gatech!willis1.cis.uab.edu!hyatt
- From: hyatt@cis.uab.edu (Robert Hyatt)
- Subject: Re: UNIX fseek time (was Re: Comparison of Alpha, MIPS and PA-RISC-II wanted)
- Message-ID: <1992Dec24.151500.11047@cis.uab.edu>
- Organization: University of Alabama at Birmingham
- References: <1992Dec21.194657.759@qb.rhein-main.de> <fW0DHHa@quack.sac.ca.us> <1992Dec24.112422.12434@titan.inmos.co.uk>
- Date: Thu, 24 Dec 1992 15:15:00 GMT
- Lines: 35
-
- In article <1992Dec24.112422.12434@titan.inmos.co.uk> conor@lion.inmos.co.uk (Conor O'Neill) writes:
- >>
- >>That's an interesting point. I am not an expert in Unix file access
- >>but I'd guess that Unix has standardized on both sequential
- >>and flat direct-access files, and that sequential access is just a
- >>special case of direct access: read so many bytes sequentially from
- >>a randomly-accessible point in a file. Or, it has standardized on
- >>sequential file access, and that direct access is a special case, using
- >>the fseek() library call.
- >
- >But, given that 'fseek' is incredibly slow on most Unix systems,
- >one could almost assume that Unix doesn't support random-access files.
- >
-
- If you look at how unix maintains a file's data blocks, you will see that
- it is based on random I/O. There are direct pointers to the first ten
- blocks of a file, a pointer to a block of pointers for the next "n" blocks
- of the file (N depends on the blocksize/wordsize of the machine), a pointer
- to a block of pointers which points to blocks of pointers for the next
- n*n blocks of the file, etc. In essence, everything is offset from the
- first byte of the file and there are no "links" or whatever within a
- block for sequential access. To access a file sequentially, you simply
- increment through the pointers sequentially.
-
- As to it being slow, I haven't noticed it being any slower than most any
- system call.... there IS a lot of work to cross the kernel boundary and
- then get back. fseek() doens't do much work, just computes where the
- next block is. If it is not pretty close to the last block (excepting
- the first 10 blocks of the file) it might have to do I/O to read in the
- "indirect" pointer blocks. However, just like any system, random access
- has it's penalty.
-
- --
- !Robert Hyatt Computer and Information Sciences !
- !hyatt@cis.uab.edu University of Alabama at Birmingham !
-