
CHAPTER 13 SERVICE CALLS
User’s Manual U14833EJ2V0UM
251
Get Memory Block from Variable-Size Memory Pool
get_mpl
[Overview]
Acquires a memory block
[C format]
#include <kernel.h>
ER get_mpl(ID mplid, UINT blksz, VP *p_blk);
[Parameters]
I/O
Parameter
Description
I
ID
mplid
ID number of variable-length memory pool from which memory block is to
be acquired
I
UINT
blksz
Requested block size [bytes]
O
VP *
p_blk
Address to store address of memory block
[Explanation]
A memory block of the size specified by blksz is acquired from the variable-length memory pool specified by mplid,
and the first address of the memory block is stored in the address specified by p_blk.
The requested size blksz must be a value that is an integral multiple of 8. If any other value is specified, a size that
is the lowest integral multiple of 8 greater than blksz is automatically assumed. The actual size of the memory block
extracted from the memory pool is greater than the specified size because a header area that manages the memory
block is included.
If no vacant memory block exists in the memory pool when get_mpl is issued, the task waits for the memory block
and is registered to the waiting task queue of the memory pool until it can acquire the memory block. The task is
registered to the queue in the order (on an FIFO basis or according to priority) specified when the memory pool was
created. If a memory block is released by rel_mpl, it is checked whether a waiting task can get the memory block in
the order in which the tasks were placed in the queue. If two or more tasks are waiting, therefore, they may be
blocked by a task requesting a larger size. Consequently, the tasks may be kept waiting even though the requested
size is smaller than the vacant area of the memory pool.
Tasks placed in the waiting state due to get_mpl are released from waiting by one of the following occurrences.
1.
(i)rel_mpl is issued and the task acquires a memory block (E_OK).
2.
A blocking task is released from the waiting task queue and acquires a memory block (E_OK).
3.
(i)rel_wai is issued and the task is forcibly released from the waiting state (E_RLWAI).
4.
del_mpl is issued and the memory pool is deleted (E_DLT).