home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / amiga / programm / 13232 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  2.6 KB

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