Chapter 3 Introduction to MR308
- 44 -

3.5.9 Memory pool Management Function

The memorypool management function provides system memory space (RAM space) dynamic control.
This function is used to manage a specific memory area (memorypool), dynamically obtain memory blocks from
the memorypool as needed for tasks or handlers, and release unnecessary memory blocks to the memorypool.
The MR308 supports two types of memorypool management functions, one for fixed-size and the other for
variable-size.
Fixed-size Memory pool Management Function
You specify memory block size using configuration file.
The MR308 kernel offers the following Fixed-size memory pool management service calls.
Acquire Fixed-size Memory Block (get_mpf, tget_mpf)
Acquires a memory block from the fixed-size memory pool that has the specified ID. If there are no
blank memory blocks in the specified fixed-size memory pool, the task that issued this service call
goes to WAITING state and is enqueued in a waiting queue.
Acquire Fixed-size Memory Block (polling) (pget_mpf, ipget_mpf)
Acquires a memory block from the fixed-size memory pool that has the specified ID. The difference
from the get_mpf and tget_mpf service calls is that if there are no blank memory blocks in the memory
pool, the task returns error code without going to WAITING state.
Fixed Length Memorypool
Memory Block 1:
Memory Block 2:
Memory Block 3:
Used by TaskA
Used by TaskB
Memor
y
block acquisition
request
Memory block acquisition
TaskC
Memor
y
block acquisition
request
No blank memory
blocks available
TaskD
Goes to a
wait state
Figure 3.35 Memory Pool Management
Release Fixed-size Memory Block (rel_mpf, irel_mpf)
Frees the acquired memory block. If there are any tasks in a wait state for the specified fixed-size
memory pool, the task enqueued at the top of the waiting queue is assigned the freed memory block.
In this case, the task changes its state from WAITING state to READY state. If there are no tasks in a
wait state, the memory block is returned to the memory pool.
Reference Fixed-size Memory Pool Status (ref_mpf, iref_mpf)
Checks the number and the size of blank blocks available in the target memory pool.