CMSIS-RTOS RTX  Version 4.51
CMSIS-RTOS RTX: Real-Time Operating System for Cortex-M processor-based devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Memory Pool Management

Define and manage fixed-size memory pools. More...

Macros

#define osFeature_Pool   1
 Memory Pools: 1=available, 0=not available.
 
#define osPoolDef(name, no, type)
 Define a Memory Pool.
 
#define osPool(name)   &os_pool_def_##name
 Access a Memory Pool definition.
 

Functions

osPoolId osPoolCreate (const osPoolDef_t *pool_def)
 Create and Initialize a memory pool.
 
void * osPoolAlloc (osPoolId pool_id)
 Allocate a memory block from a memory pool.
 
void * osPoolCAlloc (osPoolId pool_id)
 Allocate a memory block from a memory pool and set memory block to zero.
 
osStatus osPoolFree (osPoolId pool_id, void *block)
 Return an allocated memory block back to a specific memory pool.
 

Description

The Memory Pool Management function group is used to define and manage fixed-sized memory pools.

Macro Definition Documentation

#define osFeature_Pool   1

A CMSIS-RTOS implementation may support fixed-size memory pools. When the value osFeature_Pool is 1 memory pools are supported. When the value osFeature_Pool is 0 no memory pools are supported.

#define osPool (   name)    &os_pool_def_##name

Access a memory pool for the functions osPoolCreate.

Parameters
namename of the memory pool
Note
CAN BE CHANGED: The parameter to osPool shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.
#define osPoolDef (   name,
  no,
  type 
)

Define a memory pool that is referenced by osPool.

Parameters
namename of the memory pool.
nomaximum number of blocks (objects) in the memory pool.
typedata type of a single block (object).
Note
CAN BE CHANGED: The parameter to osPoolDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Function Documentation

void * osPoolAlloc ( osPoolId  pool_id)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
Returns
address of the allocated memory block or NULL in case of no memory available.
Note
MUST REMAIN UNCHANGED: osPoolAlloc shall be consistent in every CMSIS-RTOS.

Allocate a memory block from the memory pool.

void * osPoolCAlloc ( osPoolId  pool_id)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
Returns
address of the allocated memory block or NULL in case of no memory available.
Note
MUST REMAIN UNCHANGED: osPoolCAlloc shall be consistent in every CMSIS-RTOS.

Allocate a memory block from the memory pool. The block is initialized to zero.

osPoolId osPoolCreate ( const osPoolDef_t pool_def)
Parameters
[in]pool_defmemory pool definition referenced with osPool.
Returns
memory pool ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osPoolCreate shall be consistent in every CMSIS-RTOS.

Create and initialize a memory pool.

osStatus osPoolFree ( osPoolId  pool_id,
void *  block 
)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
[in]blockaddress of the allocated memory block that is returned to the memory pool.
Returns
status code that indicates the execution status of the function.
Note
MUST REMAIN UNCHANGED: osPoolFree shall be consistent in every CMSIS-RTOS.

Return a memory block to a memory pool.

Status and Error Codes

  • osOK: the memory block is released.
  • osErrorValue: block does not belong to the memory pool.
  • osErrorParameter: a parameter is invalid or outside of a permitted range.