home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / a220_1 / Docs / Memory < prev    next >
Text File  |  1993-03-02  |  2KB  |  43 lines

  1.  
  2. Technical description of the Dynamic Memory Library version 2
  3. -------------------------------------------------------------
  4.  
  5. This library supplies the 'Basic' user with dynamic memory allocation. The
  6. library allows convenient memory allocation, and more importantly
  7. deallocation, something lacking from Basic V.
  8.  
  9. This document contains information about the internal working of the
  10. library. You do not need to know how it works to use it.
  11.  
  12. When allocating memory the library will first scan it's free memory list for
  13. a block of the relevant size (or greater) using the first-fit algorithm.
  14. If this fails it will claim extra memory from either Basic itself (via
  15. the DIM command) or from the WIMP (by expanding the wimpslot for the
  16. application). Where the library gets new memory from is defined by a
  17. global variable _memdim% (set via library procedures) which if TRUE makes it
  18. claim using the DIM command, and if FALSE memory is claimed from the free
  19. memory pool.
  20.  
  21. When memory is deallocated (using PROCfree) the block is inserted into the
  22. free space list, joining it up with neighbouring blocks if possible. The free
  23. space list is an ordered list, ordered by address. A check is also made to see
  24. if the wimpslot can safely be reduced because of the deallocation. 
  25.  
  26. Version 2 of the library allocates memory in multiples of 16 bytes (version 1
  27. used multiples of 4). There is also an overhead of 4 bytes per block.
  28.  
  29. The library performs no integrity checks what-so-ever, and thus any program
  30. which writes over the end of an allocated block may cause the library to
  31. crash or behave incorrectly (although this may not become apparent for some
  32. time). This library has been extensively tested and contains no known bugs
  33. or problems.
  34.  
  35. Version 2 of the memory library is much faster then version 1 due to the
  36. fact that much of it is not written in assembler (assembled during PROCmemory).
  37. As a consequence it is actually faster then OS_HEAP in general use.
  38.  
  39. The library also supplies a memory copying routine available for general use.
  40. This routine will copy a given number of bytes (must be a multiple of 4) from
  41. a source address (must be word aligned) to a destination address (aligned).
  42.  
  43.