]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/RTOS2/src/cmsis_os2_MemPool.txt
RTOS2 Doc
[cmsis] / CMSIS / DoxyGen / RTOS2 / src / cmsis_os2_MemPool.txt
1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2 //  ==== Memory Pool Management ====
3 /** 
4 \addtogroup CMSIS_RTOS_PoolMgmt Memory Pool
5 \ingroup CMSIS_RTOS
6 \brief Manage thread-safe fixed-size blocks of dynamic memory.
7 \details
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.
10
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.
14
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:
19 \code{.c}
20 typedef struct {
21   uint32_t length;
22   uint32_t width;
23   uint32_t height;
24   uint32_t weight;
25 } properties_t;
26 \endcode
27 -# Declare a memory pool of these objects as a block of memory:
28 \code{.c}
29 osMemoryPoolId_t  object_pool_id;                 // Memory pool ID
30 \endcode
31 -# Then, create the memory pool in a thread:
32 \code{.c}
33 object_pool_id = osMemoryPoolNew(16, sizeof(properties_t), NULL);
34 \endcode
35 -# Allocate the pool within a thread and fill it with data:
36 \code{.c}
37 properties_t *object_data;
38 *object_data = (properties_t *) osPoolAlloc(object_pool_id);
39  
40 object_data->length = 100;
41 object_data->width  = 10;
42 object_data->height = 23;
43 object_data->weight = 1000;
44 \endcode
45
46 @{
47 */
48
49 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
50 /** 
51 \typedef osMemoryPoolId_t
52 \details 
53  
54 */
55 /** 
56 \struct osMemoryPoolAttr_t
57 \details 
58  
59 */
60 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
61 /** 
62 \fn osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)
63 \details
64
65 */
66 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
67 /** 
68 \fn void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout)
69 \details
70
71 */
72 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
73 /** 
74 \fn osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block)
75 \details
76
77 */
78 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
79 /** 
80 \fn uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id)
81 \details
82
83 */
84 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
85 /** 
86 \fn uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id)
87 \details
88
89 */
90 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
91 /** 
92 \fn uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id)
93 \details
94
95 */
96 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
97 /** 
98 \fn uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id)
99 \details
100
101 */
102 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
103 /** 
104 \fn osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id)
105 \details
106
107 */
108 /// @}