RKH
|
Defines the data structure used to memory block pool facility. More...
#include <rkhmempool.h>
Data Fields | |
void * | free |
The head of the linked list of free blocks. More... | |
RKH_MPNB_T | nfree |
Number of free blocks remaining. | |
RKH_MPNB_T | nblocks |
Total number of blocks in bytes. More... | |
RKH_MPBS_T | bsize |
Maximum block size in bytes. More... | |
void * | start |
The start of the original pool buffer. More... | |
void * | end |
The last block in this pool. | |
RKH_MPNB_T | nmin |
Minimum number of free blocks ever in this pool, i.e. holds the lowest number of free blocks ever present in the pool. More... | |
RKH_MPI_T | mpi |
More... | |
Defines the data structure used to memory block pool facility.
Since memory block pools consist of fixed-size blocks, there are never any fragmentation problems. Of course, fragmentation causes behavior that is inherently un-deterministic. In addition, the time required to allocate and free a fixed-size memory is comparable to that of simple linked-list manipulation. Lack of flexibility is the main drawback of fixed-size memory pools. The block size of a pool must be large enough to handle the worst case memory requirements of its users. Of course, memory may be wasted if many different size memory requests are made to the same pool. A possible solution is to make several different memory block pools that contain different sized memory blocks. Each memory block pool is a public resource.
The memory block pools contain a number of fixed-size blocks. The block size, in bytes, is specified during creation of the pool. Each memory block in the pool imposes a small amount of overhead the size of a C pointer. In addition, RKH may pad the block size in order to keep the beginning of each memory block on proper alignment.
The number of memory blocks in a pool depends on the block size and the total number of bytes in the memory area supplied during creation. To calculate the capacity of a pool (number of blocks that will be available), divide the block size (including padding and the pointer overhead bytes) into the total number of bytes in the supplied memory area.
The memory area for the block pool is specified during creation, and can be located anywhere in the target's address space. This is an important feature because of the considerable flexibility it gives the application.
Definition at line 191 of file rkhmempool.h.
void* free |
The head of the linked list of free blocks.
The only data member strictly required for allocating and freeing blocks in the pool is the head of the free list 'free'.
Definition at line 200 of file rkhmempool.h.
RKH_MPNB_T nblocks |
Total number of blocks in bytes.
The type RKH_MPNB_T is configurable by the macro RKH_CFG_MP_SIZEOF_NBLOCK. The valid values [in bits] are 8, 16 or 32. Default is 8. The dynamic range of the RKH_MPNB_T data type determines the maximum number of blocks that can be stored in the pool.
Definition at line 218 of file rkhmempool.h.
RKH_MPBS_T bsize |
Maximum block size in bytes.
The type RKH_MPBS_T is configurable by the macro RKH_CFG_MP_SIZEOF_BSIZE. The valid values [in bits] are 8, 16 or 32. Default is 8. The dynamic range of the RKH_MPBS_T data type determines the maximum size of blocks that can be managed by the pool manager.
Definition at line 230 of file rkhmempool.h.
void* start |
The start of the original pool buffer.
The start and end pointers are used as delimiters of the valid range of memory blocks managed by this pool.
Definition at line 240 of file rkhmempool.h.
RKH_MPNB_T nmin |
Minimum number of free blocks ever in this pool, i.e. holds the lowest number of free blocks ever present in the pool.
The nmin low-watermark provides valuable empirical data for proper sizing of the memory pool.
Definition at line 257 of file rkhmempool.h.
RKH_MPI_T mpi |
Performance information. This member is optional, thus it could be eliminated in compile-time with RKH_CFG_MP_GET_INFO_EN.
Definition at line 267 of file rkhmempool.h.