摘要 |
A method and apparatus for allocating and deallocating memory in a multi-processing system. Each unit of user memory has an associated control block. All units of user memory are contiguous as are all control blocks. Available user memory blocks are stored in linked lists, one linked list for each range of user memory block sizes. When a user memory block is allocated, a memory block is seized using a linked list of adequate size memory blocks; the surplus of the adequate size memory block beyond what is needed in the request for user memory is retained as available user memory and is added to another appropriate linked list of available memory. When deallocating, both the memory block being deallocated and, if available, the previous and/or next memory block are added to create a merged memory block. The merged memory block is then restored as available memory and added to the appropriate one of the linked lists of available memory blocks while the previous and/or next memory blocks, if available, are removed from the list of available memory blocks of the size of the previous or next block.
|