home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cbmvax!mks
- From: mks@cbmvax.commodore.com (Michael Sinz)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: writing odd bytes
- Message-ID: <35011@cbmvax.commodore.com>
- Date: 10 Sep 92 13:39:19 GMT
- References: <1992Sep6.848.16300@dosgate>
- Reply-To: mks@cbmvax.commodore.com (Michael Sinz)
- Distribution: comp
- Organization: Commodore, West Chester, PA
- Lines: 40
-
- "jonathan forbes" <jonathan.forbes@canrem.com> writes:
- >I have run into a very strange problem. In one of my programs, a
- >Write() call will occasionally take *much* longer to execute than it
- >should (when writing to any hard drive). When this happens, it would
- >seem to be a slowdown to about 25% of "normal" speed, and the hard drive
- >activity light is solid.
- >
- >It's almost as if the data was being written a little bit at a time, but
- >I have checked and only large pieces are being written (~= 64k).
- >
- >Now, the strange thing I noticed eventually is that writing an odd
- >number of bytes seems to make it happen; I can write 65534 or 65536
- >bytes, but if I write 65535 bytes, it slows down.
- >
- >Even weirder; I wrote a tiny program to try to test this out (writing
- >65535 bytes ten times to a new file) but it didn't have any effect
- >there.
- >
- >Note that even though it takes 4 times long to write the data, the data
- >written *is* correct.
-
- What is happening is this: If the data you are writing starts at an odd
- address or the sector it must write to starts in your data at an odd-byte
- address, things will be slow. Why? Well, most of the DMA controllers on
- the AMIGA do either 16-bit or 32-bit DMA. When they have to get a single
- byte (or word) since it is at an odd address, they have to hand-feed the
- device. This can take much longer (CPU-I/O) than DMA. Also, in some
- cases, the transfer mask is set such that the filesystems knows this fact
- and will not transfer the data directly but first move it into a DMA buffer
- and then transfer with DMA from there. This is also much slower since the
- transfer to the DMA buffer takes a while and then the DMA buffer is small
- and thus does small DMA requests. This is also slow.
-
- /----------------------------------------------------------------------\
- | /// Michael Sinz - Senior Amiga Systems Engineer |
- | /// Operating System Development Group |
- | /// BIX: msinz UUNET: mks@cbmvax.commodore.com |
- |\\\/// Programming is like sex: |
- | \XX/ One mistake and you have to support it for life. |
- \----------------------------------------------------------------------/
-