1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2 // ==== Memory Pool Management ====
4 \addtogroup CMSIS_RTOS_PoolMgmt Memory Pool
6 \brief Manage thread-safe fixed-size blocks of dynamic memory.
8 \b Memory \b pools are fixed-size blocks of memory that are thread-safe. They operate much faster than the dynamically
9 allocated heap and do not suffer from fragmentation. Being thread-safe, they can be accessed from threads and ISRs alike.
11 \b Shared \b memory is one of the basic models to exchange information between threads. Using memory pools for exchanging
12 data, you can share more complex objects between threads if compared to a \ref CMSIS_RTOS_Message. Memory pool management
13 functions are used to define and manage such fixed-sized memory pools.
15 Working with Memory Pools
16 -------------------------
17 Follow these steps to create and use a memory pool:
18 -# Declare a data structure that combines a number of elements:
27 -# Declare a memory pool of these objects as a block of memory:
29 osMemoryPoolId_t object_pool_id; // Memory pool ID
31 -# Then, create the memory pool in a thread:
33 object_pool_id = osMemoryPoolNew(16, sizeof(properties_t), NULL);
35 -# Allocate the pool within a thread and fill it with data:
37 properties_t *object_data;
38 *object_data = (properties_t *) osPoolAlloc(object_pool_id);
40 object_data->length = 100;
41 object_data->width = 10;
42 object_data->height = 23;
43 object_data->weight = 1000;
49 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
51 \typedef osMemoryPoolId_t
56 \struct osMemoryPoolAttr_t
60 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
62 \fn osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)
66 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
68 \fn void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout)
72 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
74 \fn osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block)
78 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
80 \fn uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id)
84 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
86 \fn uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id)
90 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
92 \fn uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id)
96 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
98 \fn uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id)
102 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
104 \fn osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id)