Chapter 3 Introduction to MR308
- 45 -
Variable-size Memory Pool Management Function
The technique that allows you to arbitrary define the size of memory block acquirable from the memory pool is
termed Variable-size scheme. The MR308 manages memory in terms of four fixed-size memory block sizes.
The MR308 calculates the size of individual blocks based on the maximum memory block size to be acquired.
You specify the maximum memory block size using the configuration file.
e.g.
variable_memorypool[]{
max_memsize = 400; <---- Maximum size
heap_size = 5000;
};
Defining a variable-size memory pool as shown above causes four fixed-size memory block sizes to become 56
bytes, 112 bytes, 224 bytes, and 448 bytes in compliance with max_memsize.
In the case of user-requested memory, the MR308 performs calculations based on the specified size and se-
lects and allocates the optimum one of four fixed-size memory block sizes. The MR308 cannot allocate a mem-
ory block that is not one of the four sizes.
Service calls the MR308 provides include the following.
Acquire Variable-size Memory Block (pget_mpl)
Round off a block size you specify to the optimal block size among the four block sizes, and acquires
memory having the rounded-off size from the memory pool.
The following equations define the block sizes:
a = (((max_memsize+(X-1))/ X × 8)+1) × 8
b = a × 2
c = a × 4
d = a × 8
max_memsize: the value specified in the configuration file
X: data size for block control (8 byte)
For example, if you request 200-byte, the MR308 rounds off the size to 244 bytes, and acquires
244-byte memory.
If memory acquirement goes well, the MR308 returns the first address of the memory acquired along
with the error code "E_OK". If memory acquirement fails, the MR308 returns the error code
"E_TMOUT".