
CHAPTER 6 MEMORY MANAGEMENT
User’s Manual U14833EJ2V0UM
70
6.3
Stack Pool
The stack pool is used to secure the interrupt stack area used by interrupt service routines, etc., and the task stack
area provided for each task.
Dynamic creation/deletion of the interrupt stack is assumed not to occur during system operation, and because the
stack size is determined according to a description in the CF definition file, the interrupt stack area is statically secured
as an undeletable area at kernel initialization.
Sections from the stack pool other than the area for the interrupt stack are initialized as a single large variable-
length memory pool controlled by the kernel. When a task is created, a memory block secured from this memory pool
is assigned to the task as a stack. When a task is deleted, the stack area is returned to this memory pool.
Note that this memory pool cannot be directly accessed from a task or handler processing program via a service
call.
6.4
User Pool
The user pool is used to secure the main body of the fixed-length and variable-length memory pools and the ring
buffer area used for the data queue.
The user pool is initialized as a single large variable-length memory pool from which memory blocks are secured in
memory pool or ring buffer sized portions when a fixed-length memory pool, variable-length memory pool, or data
queue is created. The secured memory blocks are assigned to objects created as the main body of a fixed-length
memory pool.
Note that this memory pool (user pool) cannot be directly accessed from a task or handler processing program via
a service call.
6.5
Fixed-Length Memory Pools
These are memory pools from which memory blocks can be repeatedly acquired and returned by a task or handler
processing program via a service call. Unlike a variable-length memory pool, the size of the memory blocks that can
be acquired is fixed for each memory pool, enabling more simple and faster access by the processing.
6.5.1
Creating fixed-length memory pools
A fixed-length memory pool is created by issuing the service call (a)cre_mpf. When acre_mpf is issued, the ID
number of the memory pool can be assigned by the kernel. Also, specifying the static API CRE_MPF allows
processing equivalent to cre_mpf to be carried out at kernel initialization.
When (a)cre_mpf is issued, an area of the specified size is secured from the user pool and becomes the memory
pool main body. If this area is successfully secured, data such as the attribute and the address of the memory pool
main body area is stored in the fixed-length memory control block corresponding to the specified ID number, and the
area is initialized.
6.5.2
Deleting fixed-length memory pools
A fixed-length memory pool is deleted by issuing the service call del_mpf. When del_mpf is issued, the kernel
returns the area of the memory pool main body to the user pool and then invalidates the control block. At this time, if
there is a task waiting to acquire a memory block from the fixed-length memory pool to be deleted, all tasks are
released from the waiting state. For tasks released from waiting, the error code E_DLT is returned indicating that the
memory pool was deleted.
Note that even if there are parts of memory blocks in the target fixed-length memory pool that have not been
returned, the fixed-length memory pool will still be deleted. Care is required at this time because the task or handler
that had acquired that memory block is not informed of the deletion of the memory pool.