
CHAPTER 6 MEMORY MANAGEMENT
User’s Manual U14833EJ2V0UM
72
6.5.5
Acquiring fixed-length memory blocks
A memory block is acquired from a fixed-length memory pool by issuing one of the service calls get_mpf,
(i)pget_mpf, or tget_mpf.
If there is a request to acquire a memory block, the kernel checks the memory block queue of the target memory
pool. If the queue has memory blocks queued in it, the task is assigned the memory block at the top of the queue. If
there are no queued memory blocks, the task is put in the memory block acquisition waiting state, and waits until a
memory block has been acquired, in the case of get_mpf, or until either a memory block has been acquired or a
specified time has elapsed, in the case of tget_mpf. The issuance of (i)pget_mpf results in an error, and the error
code E_TMOUT is returned, indicating that polling failed.
Tasks in the memory block acquisition waiting state are registered in the waiting task queue of the memory pool.
The waiting order at this time depends on the attribute of the memory pool: in FIFO order if the attribute is TA_TFIFO
or in priority order if the attribute is TA_TPRI, and if (i)rel_mpf is issued, memory blocks are acquired in the order they
are queued, and the task is released from waiting.
Note that because 0 is stored in the top four bytes of the acquired memory block, when this memory block is
transmitted to a mailbox as a message, because no value other than 0 is stored in this area (which is used by the
kernel to manage the message), it is possible to check whether a memory block has been registered in the mailbox by
checking the top four bytes.
6.5.6 Returning fixed-length memory blocks
A memory block is returned to a fixed-length memory pool by issuing the service call (i)rel_mpf.
If there is a request to return a memory block, the kernel checks the waiting task queue of the target memory pool,
and if there are tasks registered in the queue, it immediately assigns the task at the top of the queue the returned
memory block and releases it from the waiting state. If there are no tasks registered in the waiting queue, the memory
block is returned to the bottom of the memory pool’s free memory block queue.
Note that memory blocks must be returned to the same memory pool from which they were acquired. If a different
memory pool is specified and (i)rel_mpf is issued, operation cannot be guaranteed. Neither can operation be
guaranteed if areas other than fixed-length memory blocks, such as variable-length memory blocks or statically
secured areas, are registered together in a mailbox as messages and (i)rel_mpf is issued.
6.5.7
Obtaining fixed-length memory pool information
Fixed-length memory pool information such as the presence or absence of a waiting task can be obtained by using
the service calls ref_mpf and iref_mpf. For details of each service call, refer to
CHAPTER 13
.