]> begriffs open source - cmsis/blob - main/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html
Initial contribution
[cmsis] / main / RTOS2 / html / group__CMSIS__RTOS__PoolMgmt.html
1 <!-- HTML header for doxygen 1.9.6-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
4 <head>
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=11"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>CMSIS-RTOS2: Memory Pool</title>
9 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
10 <link href="tabs.css" rel="stylesheet" type="text/css"/>
11 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
12 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
13 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="jquery.js"></script>
15 <script type="text/javascript" src="dynsections.js"></script>
16 <script type="text/javascript" src="printComponentTabs.js"></script>
17 <script type="text/javascript" src="footer.js"></script>
18 <script type="text/javascript" src="navtree.js"></script>
19 <link href="navtree.css" rel="stylesheet" type="text/css"/>
20 <script type="text/javascript" src="resize.js"></script>
21 <script type="text/javascript" src="navtreedata.js"></script>
22 <script type="text/javascript" src="navtree.js"></script>
23 <link href="search/search.css" rel="stylesheet" type="text/css"/>
24 <script type="text/javascript" src="search/searchdata.js"></script>
25 <script type="text/javascript" src="search/search.js"></script>
26 <script type="text/javascript">
27 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
28   $(document).ready(function() { init_search(); });
29 /* @license-end */
30 </script>
31 <script type="text/javascript" src="darkmode_toggle.js"></script>
32 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
33 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
34 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
35 <link href="version.css" rel="stylesheet" type="text/css" />
36 <script type="text/javascript" src="../../version.js"></script>
37 </head>
38 <body>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
40 <div id="titlearea">
41 <table cellspacing="0" cellpadding="0">
42  <tbody>
43  <tr style="height: 55px;">
44   <td id="projectlogo" style="padding: 1.5em;"><img alt="Logo" src="cmsis_logo_white_small.png"/></td>
45   <td style="padding-left: 1em; padding-bottom: 1em;padding-top: 1em;">
46    <div id="projectname">CMSIS-RTOS2
47    &#160;<span id="projectnumber"><script type="text/javascript">
48      <!--
49      writeHeader.call(this);
50      writeVersionDropdown.call(this, "CMSIS-RTOS2");
51      //-->
52     </script>
53    </span>
54    </div>
55    <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div>
56   </td>
57    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
58         <span class="left">
59           <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
60           <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
61                onfocus="searchBox.OnSearchFieldFocus(true)" 
62                onblur="searchBox.OnSearchFieldFocus(false)" 
63                onkeyup="searchBox.OnSearchFieldChange(event)"/>
64           </span><span class="right">
65             <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
66           </span>
67         </div>
68 </td>
69   <!--END !PROJECT_NAME-->
70  </tr>
71  </tbody>
72 </table>
73 </div>
74 <!-- end header part -->
75 <div id="CMSISnav" class="tabs1">
76   <ul class="tablist">
77     <script type="text/javascript">
78       writeComponentTabs.call(this);
79     </script>
80   </ul>
81 </div>
82 <!-- Generated by Doxygen 1.9.6 -->
83 <script type="text/javascript">
84 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
85 var searchBox = new SearchBox("searchBox", "search/",'.html');
86 /* @license-end */
87 </script>
88 </div><!-- top -->
89 <div id="side-nav" class="ui-resizable side-nav-resizable">
90   <div id="nav-tree">
91     <div id="nav-tree-contents">
92       <div id="nav-sync" class="sync"></div>
93     </div>
94   </div>
95   <div id="splitbar" style="-moz-user-select:none;" 
96        class="ui-resizable-handle">
97   </div>
98 </div>
99 <script type="text/javascript">
100 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
101 $(document).ready(function(){initNavTree('group__CMSIS__RTOS__PoolMgmt.html',''); initResizable(); });
102 /* @license-end */
103 </script>
104 <div id="doc-content">
105 <!-- window showing the filter options -->
106 <div id="MSearchSelectWindow"
107      onmouseover="return searchBox.OnSearchSelectShow()"
108      onmouseout="return searchBox.OnSearchSelectHide()"
109      onkeydown="return searchBox.OnSearchSelectKey(event)">
110 </div>
111
112 <!-- iframe showing the search results (closed by default) -->
113 <div id="MSearchResultsWindow">
114 <div id="MSearchResults">
115 <div class="SRPage">
116 <div id="SRIndex">
117 <div id="SRResults"></div>
118 <div class="SRStatus" id="Loading">Loading...</div>
119 <div class="SRStatus" id="Searching">Searching...</div>
120 <div class="SRStatus" id="NoMatches">No Matches</div>
121 </div>
122 </div>
123 </div>
124 </div>
125
126 <div class="header">
127   <div class="summary">
128 <a href="#nested-classes">Data Structures</a> &#124;
129 <a href="#typedef-members">Typedefs</a> &#124;
130 <a href="#func-members">Functions</a>  </div>
131   <div class="headertitle"><div class="title">Memory Pool<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div></div>
132 </div><!--header-->
133 <div class="contents">
134
135 <p>Manage thread-safe fixed-size blocks of dynamic memory.  
136 <a href="#details">More...</a></p>
137 <table class="memberdecls">
138 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
139 Data Structures</h2></td></tr>
140 <tr class="memitem:structosMemoryPoolAttr__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a></td></tr>
141 <tr class="memdesc:structosMemoryPoolAttr__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attributes structure for memory pool.  <a href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">More...</a><br /></td></tr>
142 <tr class="separator:structosMemoryPoolAttr__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
143 </table><table class="memberdecls">
144 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
145 Typedefs</h2></td></tr>
146 <tr class="memitem:ga2e44473caf338266f56800960294f960"><td class="memItemLeft" align="right" valign="top">typedef void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td></tr>
147 <tr class="separator:ga2e44473caf338266f56800960294f960"><td class="memSeparator" colspan="2">&#160;</td></tr>
148 </table><table class="memberdecls">
149 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
150 Functions</h2></td></tr>
151 <tr class="memitem:ga497ced5d72dc5cd405c4c418516220dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> (uint32_t block_count, uint32_t block_size, const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> *attr)</td></tr>
152 <tr class="memdesc:ga497ced5d72dc5cd405c4c418516220dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create and Initialize a Memory Pool object.  <br /></td></tr>
153 <tr class="separator:ga497ced5d72dc5cd405c4c418516220dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
154 <tr class="memitem:gab414a1e138205a55820acfa277c8f386"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab414a1e138205a55820acfa277c8f386">osMemoryPoolGetName</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
155 <tr class="memdesc:gab414a1e138205a55820acfa277c8f386"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get name of a Memory Pool object.  <br /></td></tr>
156 <tr class="separator:gab414a1e138205a55820acfa277c8f386"><td class="memSeparator" colspan="2">&#160;</td></tr>
157 <tr class="memitem:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id, uint32_t timeout)</td></tr>
158 <tr class="memdesc:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate a memory block from a Memory Pool.  <br /></td></tr>
159 <tr class="separator:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
160 <tr class="memitem:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id, void *block)</td></tr>
161 <tr class="memdesc:gabb4f4560daa6d1f8c8789082ee186d16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return an allocated memory block back to a Memory Pool.  <br /></td></tr>
162 <tr class="separator:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memSeparator" colspan="2">&#160;</td></tr>
163 <tr class="memitem:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gad696e94bfbe28f0b6613f9303fdf6a37">osMemoryPoolGetCapacity</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
164 <tr class="memdesc:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get maximum number of memory blocks in a Memory Pool.  <br /></td></tr>
165 <tr class="separator:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memSeparator" colspan="2">&#160;</td></tr>
166 <tr class="memitem:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab2bf059b7fa7679c3cccdaeec60b6c0e">osMemoryPoolGetBlockSize</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
167 <tr class="memdesc:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get memory block size in a Memory Pool.  <br /></td></tr>
168 <tr class="separator:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
169 <tr class="memitem:ga958a9449bff8c95ce213de98eef5739d"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga958a9449bff8c95ce213de98eef5739d">osMemoryPoolGetCount</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
170 <tr class="memdesc:ga958a9449bff8c95ce213de98eef5739d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks used in a Memory Pool.  <br /></td></tr>
171 <tr class="separator:ga958a9449bff8c95ce213de98eef5739d"><td class="memSeparator" colspan="2">&#160;</td></tr>
172 <tr class="memitem:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga0394cffa9479a7994e3b03c79c1cb909">osMemoryPoolGetSpace</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
173 <tr class="memdesc:ga0394cffa9479a7994e3b03c79c1cb909"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks available in a Memory Pool.  <br /></td></tr>
174 <tr class="separator:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memSeparator" colspan="2">&#160;</td></tr>
175 <tr class="memitem:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8c39e7e5cd2b9eda907466808e59d62e">osMemoryPoolDelete</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
176 <tr class="memdesc:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete a Memory Pool object.  <br /></td></tr>
177 <tr class="separator:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memSeparator" colspan="2">&#160;</td></tr>
178 </table>
179 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
180 <p><b>Memory</b> <b>Pools</b> are fixed-size blocks of memory that are thread-safe. They operate much faster than the dynamically allocated heap and do not suffer from fragmentation. Being thread-safe, they can be accessed from threads and ISRs alike.</p>
181 <p>A Memory Pool can be seen as a linked list of available (unused) memory blocks of fixed and equal size. Allocating memory from a pool (using <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>) simply unchains a block from the list and hands over control to the user. Freeing memory to the pool (using <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>) simply rechains the block into the list.</p>
182 <div class="image">
183 <img src="mempool.png" alt=""/>
184 <div class="caption">
185 CMSIS-RTOS Memory Pools</div></div>
186 <dl class="section note"><dt>Note</dt><dd>One must not write to freed block. It is up to the implementation to reuse the memory of unused blocks for internal control data, i.e. linked list pointers.</dd></dl>
187 <p><b>Shared</b> <b>memory</b> is one of the basic models to exchange information between threads. Using memory pools for exchanging data, you can share more complex objects between threads if compared to a <a class="el" href="group__CMSIS__RTOS__Message.html">Message Queue</a>. Memory pool management functions are used to define and manage such fixed-sized memory pools.</p>
188 <dl class="section note"><dt>Note</dt><dd>The functions <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gad696e94bfbe28f0b6613f9303fdf6a37">osMemoryPoolGetCapacity</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab2bf059b7fa7679c3cccdaeec60b6c0e">osMemoryPoolGetBlockSize</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga958a9449bff8c95ce213de98eef5739d">osMemoryPoolGetCount</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga0394cffa9479a7994e3b03c79c1cb909">osMemoryPoolGetSpace</a> can be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
189 <dd>
190 Refer to <a class="el" href="config_rtx5.html#memPoolConfig">Memory Pool Configuration</a> for RTX5 configuration options. </dd></dl>
191 <hr/><h2 class="groupheader">Data Structure Documentation</h2>
192 <a name="structosMemoryPoolAttr__t" id="structosMemoryPoolAttr__t"></a>
193 <h2 class="memtitle"><span class="permalink"><a href="#structosMemoryPoolAttr__t">&#9670;&#160;</a></span>osMemoryPoolAttr_t</h2>
194
195 <div class="memitem">
196 <div class="memproto">
197       <table class="memname">
198         <tr>
199           <td class="memname">struct osMemoryPoolAttr_t</td>
200         </tr>
201       </table>
202 </div><div class="memdoc">
203 <div class="textblock"><p>Attributes to configure a memory pool.</p>
204 <p>Refer to <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html">Memory Management</a> for details about usage of</p><ul>
205 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e" title="memory for control block">osMemoryPoolAttr_t::cb_mem</a></li>
206 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#aa55a4335d12dc2785dc00fdc292d1159" title="size of provided memory for control block">osMemoryPoolAttr_t::cb_size</a></li>
207 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a" title="memory for data storage">osMemoryPoolAttr_t::mp_mem</a></li>
208 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a66c26015c0ac8e88a4ad907c120aee4f" title="size of provided memory for data storage">osMemoryPoolAttr_t::mp_size</a> </li>
209 </ul>
210 </div><table class="fieldtable">
211 <tr><th colspan="3">Data Fields</th></tr>
212 <tr><td class="fieldtype">
213 <a id="ab74e6bf80237ddc4109968cedc58c151" name="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
214 <td class="fieldname">
215 name</td>
216 <td class="fielddoc">
217 name of the memory pool <p>Pointer to a string with a human readable name of the memory pool object.<br  />
218 Default: <span class="XML-Token">NULL</span>. </p>
219 </td></tr>
220 <tr><td class="fieldtype">
221 <a id="a6e93b49cb79c12f768d72580c7731f30" name="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
222 <td class="fieldname">
223 attr_bits</td>
224 <td class="fielddoc">
225 attribute bits <p>Reserved for future use (set to '0').<br  />
226 Default: <span class="XML-Token">0</span>. </p>
227 </td></tr>
228 <tr><td class="fieldtype">
229 <a id="a1e100dc33d403841ed3c344e3397868e" name="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
230 <td class="fieldname">
231 cb_mem</td>
232 <td class="fielddoc">
233 memory for control block <p>Pointer to a memory location for the memory pool control block object. This can optionally be used for custom memory management systems.<br  />
234 Default: <span class="XML-Token">NULL</span> (uses kernel memory management). </p>
235 </td></tr>
236 <tr><td class="fieldtype">
237 <a id="aa55a4335d12dc2785dc00fdc292d1159" name="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
238 <td class="fieldname">
239 cb_size</td>
240 <td class="fielddoc">
241 size of provided memory for control block <p>The size of the memory block passed with <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. Must be the size of a memory pool control block object or larger. </p>
242 </td></tr>
243 <tr><td class="fieldtype">
244 <a id="a5799465cca9c71c5587ceb0986f5b06a" name="a5799465cca9c71c5587ceb0986f5b06a"></a>void *</td>
245 <td class="fieldname">
246 mp_mem</td>
247 <td class="fielddoc">
248 memory for data storage <p>Pointer to a memory location for the data of the memory pool object.<br  />
249 Default: <span class="XML-Token">NULL</span>. </p>
250 </td></tr>
251 <tr><td class="fieldtype">
252 <a id="a66c26015c0ac8e88a4ad907c120aee4f" name="a66c26015c0ac8e88a4ad907c120aee4f"></a>uint32_t</td>
253 <td class="fieldname">
254 mp_size</td>
255 <td class="fielddoc">
256 size of provided memory for data storage <p>The size of the memory passed with <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a">mp_mem</a>. </p>
257 </td></tr>
258 </table>
259
260 </div>
261 </div>
262 <h2 class="groupheader">Typedef Documentation</h2>
263 <a id="ga2e44473caf338266f56800960294f960" name="ga2e44473caf338266f56800960294f960"></a>
264 <h2 class="memtitle"><span class="permalink"><a href="#ga2e44473caf338266f56800960294f960">&#9670;&#160;</a></span>osMemoryPoolId_t</h2>
265
266 <div class="memitem">
267 <div class="memproto">
268       <table class="memname">
269         <tr>
270           <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td>
271         </tr>
272       </table>
273 </div><div class="memdoc">
274 <p>Memory Pool ID identifies the memory pool.</p>
275 <p>Returned by:</p><ul>
276 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> </li>
277 </ul>
278
279 </div>
280 </div>
281 <h2 class="groupheader">Function Documentation</h2>
282 <a id="ga497ced5d72dc5cd405c4c418516220dc" name="ga497ced5d72dc5cd405c4c418516220dc"></a>
283 <h2 class="memtitle"><span class="permalink"><a href="#ga497ced5d72dc5cd405c4c418516220dc">&#9670;&#160;</a></span>osMemoryPoolNew()</h2>
284
285 <div class="memitem">
286 <div class="memproto">
287       <table class="memname">
288         <tr>
289           <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> osMemoryPoolNew </td>
290           <td>(</td>
291           <td class="paramtype">uint32_t&#160;</td>
292           <td class="paramname"><em>block_count</em>, </td>
293         </tr>
294         <tr>
295           <td class="paramkey"></td>
296           <td></td>
297           <td class="paramtype">uint32_t&#160;</td>
298           <td class="paramname"><em>block_size</em>, </td>
299         </tr>
300         <tr>
301           <td class="paramkey"></td>
302           <td></td>
303           <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> *&#160;</td>
304           <td class="paramname"><em>attr</em>&#160;</td>
305         </tr>
306         <tr>
307           <td></td>
308           <td>)</td>
309           <td></td><td></td>
310         </tr>
311       </table>
312 </div><div class="memdoc">
313 <dl class="params"><dt>Parameters</dt><dd>
314   <table class="params">
315     <tr><td class="paramdir">[in]</td><td class="paramname">block_count</td><td>maximum number of memory blocks in memory pool. </td></tr>
316     <tr><td class="paramdir">[in]</td><td class="paramname">block_size</td><td>memory block size in bytes. </td></tr>
317     <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>memory pool attributes; NULL: default values. </td></tr>
318   </table>
319   </dd>
320 </dl>
321 <dl class="section return"><dt>Returns</dt><dd>memory pool ID for reference by other functions or NULL in case of error.</dd></dl>
322 <p>The function <b>osMemoryPoolNew</b> creates and initializes a memory pool object and returns the pointer to the memory pool object identifier or <span class="XML-Token">NULL</span> in case of an error. It can be safely called before the RTOS is started (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>), but not before it is initialized (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>).</p>
323 <p>The total amount of memory needed is at least <code>block_count * block_size</code>. Memory from the pool can only be allocated/freed in fixed portions of <code>block_size</code>.</p>
324 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
325 <p><b>Code</b> <b>Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span>                          <span class="comment">// CMSIS RTOS header file</span></div>
326 <div class="line"> </div>
327 <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
328 <div class="line"><span class="comment"> *      Memory Pool creation &amp; usage</span></div>
329 <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
330 <div class="line"> </div>
331 <div class="line"><span class="preprocessor">#define MEMPOOL_OBJECTS 16                      </span><span class="comment">// number of Memory Pool Objects</span></div>
332 <div class="line"> </div>
333 <div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{                                <span class="comment">// object data type</span></div>
334 <div class="line">  uint8_t Buf[32];</div>
335 <div class="line">  uint8_t Idx;</div>
336 <div class="line">} MEM_BLOCK_t;</div>
337 <div class="line"> </div>
338 <div class="line"><a class="code hl_typedef" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mpid_MemPool;                  <span class="comment">// memory pool id</span></div>
339 <div class="line"> </div>
340 <div class="line"><a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_MemPool;                <span class="comment">// thread id</span></div>
341 <div class="line"> </div>
342 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument);           <span class="comment">// thread function</span></div>
343 <div class="line"> </div>
344 <div class="line"><span class="keywordtype">int</span> Init_MemPool (<span class="keywordtype">void</span>) {</div>
345 <div class="line"> </div>
346 <div class="line">  mpid_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>(MEMPOOL_OBJECTS, <span class="keyword">sizeof</span>(MEM_BLOCK_t), NULL);</div>
347 <div class="line">  <span class="keywordflow">if</span> (mpid_MemPool == NULL) {</div>
348 <div class="line">    ; <span class="comment">// MemPool object not created, handle failure</span></div>
349 <div class="line">  }</div>
350 <div class="line"> </div>
351 <div class="line">  tid_Thread_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_MemPool, NULL, NULL);</div>
352 <div class="line">  <span class="keywordflow">if</span> (tid_Thread_MemPool == NULL) {</div>
353 <div class="line">    <span class="keywordflow">return</span>(-1);</div>
354 <div class="line">  }</div>
355 <div class="line"> </div>
356 <div class="line">  <span class="keywordflow">return</span>(0);</div>
357 <div class="line">}</div>
358 <div class="line"> </div>
359 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument) {</div>
360 <div class="line">  MEM_BLOCK_t *pMem;</div>
361 <div class="line">  <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
362 <div class="line"> </div>
363 <div class="line">  <span class="keywordflow">while</span> (1) {</div>
364 <div class="line">    ; <span class="comment">// Insert thread code here...</span></div>
365 <div class="line"> </div>
366 <div class="line">    pMem = (MEM_BLOCK_t *)<a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>(mpid_MemPool, 0U);  <span class="comment">// get Mem Block</span></div>
367 <div class="line">    <span class="keywordflow">if</span> (pMem != NULL) {                                         <span class="comment">// Mem Block was available</span></div>
368 <div class="line">      pMem-&gt;Buf[0] = 0x55U;                                     <span class="comment">// do some work...</span></div>
369 <div class="line">      pMem-&gt;Idx    = 0U;</div>
370 <div class="line"> </div>
371 <div class="line">      status = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>(mpid_MemPool, pMem);            <span class="comment">// free mem block</span></div>
372 <div class="line">      <span class="keywordflow">switch</span> (status)  {</div>
373 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>:</div>
374 <div class="line">          <span class="keywordflow">break</span>;</div>
375 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109">osErrorParameter</a>:</div>
376 <div class="line">          <span class="keywordflow">break</span>;</div>
377 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81">osErrorNoMemory</a>:</div>
378 <div class="line">          <span class="keywordflow">break</span>;</div>
379 <div class="line">        <span class="keywordflow">default</span>:</div>
380 <div class="line">          <span class="keywordflow">break</span>;</div>
381 <div class="line">      }</div>
382 <div class="line">    }</div>
383 <div class="line"> </div>
384 <div class="line">    <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>();                                            <span class="comment">// suspend thread</span></div>
385 <div class="line">  }</div>
386 <div class="line">}</div>
387 <div class="ttc" id="acmsis__os2_8h_html"><div class="ttname"><a href="cmsis__os2_8h.html">cmsis_os2.h</a></div></div>
388 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a></div><div class="ttdeci">@ osOK</div><div class="ttdoc">Operation completed successfully.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:240</div></div>
389 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109">osErrorParameter</a></div><div class="ttdeci">@ osErrorParameter</div><div class="ttdoc">Parameter error.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:244</div></div>
390 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81">osErrorNoMemory</a></div><div class="ttdeci">@ osErrorNoMemory</div><div class="ttdoc">System is out of memory: it was impossible to allocate or reserve memory for the operation.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:245</div></div>
391 <div class="ttc" id="agroup__CMSIS__RTOS__Definitions_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813e"><div class="ttname"><a href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a></div><div class="ttdeci">osStatus_t</div><div class="ttdoc">Status code values returned by CMSIS-RTOS functions.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:239</div></div>
392 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga2e44473caf338266f56800960294f960"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></div><div class="ttdeci">void * osMemoryPoolId_t</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:268</div></div>
393 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga497ced5d72dc5cd405c4c418516220dc"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a></div><div class="ttdeci">osMemoryPoolId_t osMemoryPoolNew(uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)</div><div class="ttdoc">Create and Initialize a Memory Pool object.</div></div>
394 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga8ead54e99ccb8f112356c88f99d38fbe"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a></div><div class="ttdeci">void * osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout)</div><div class="ttdoc">Allocate a memory block from a Memory Pool.</div></div>
395 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_gabb4f4560daa6d1f8c8789082ee186d16"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a></div><div class="ttdeci">osStatus_t osMemoryPoolFree(osMemoryPoolId_t mp_id, void *block)</div><div class="ttdoc">Return an allocated memory block back to a Memory Pool.</div></div>
396 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga48d68b8666d99d28fa646ee1d2182b8f"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a></div><div class="ttdeci">osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)</div><div class="ttdoc">Create a thread and add it to Active Threads.</div></div>
397 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gaa6c32fe2a3e0a2e01f212d55b02e51c7"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></div><div class="ttdeci">void * osThreadId_t</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:253</div></div>
398 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gad01c7ec26535b1de6b018bb9466720e2"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a></div><div class="ttdeci">osStatus_t osThreadYield(void)</div><div class="ttdoc">Pass control to next thread that is in state READY.</div></div>
399 </div><!-- fragment --> 
400 </div>
401 </div>
402 <a id="gab414a1e138205a55820acfa277c8f386" name="gab414a1e138205a55820acfa277c8f386"></a>
403 <h2 class="memtitle"><span class="permalink"><a href="#gab414a1e138205a55820acfa277c8f386">&#9670;&#160;</a></span>osMemoryPoolGetName()</h2>
404
405 <div class="memitem">
406 <div class="memproto">
407       <table class="memname">
408         <tr>
409           <td class="memname">const char * osMemoryPoolGetName </td>
410           <td>(</td>
411           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
412           <td class="paramname"><em>mp_id</em></td><td>)</td>
413           <td></td>
414         </tr>
415       </table>
416 </div><div class="memdoc">
417 <dl class="params"><dt>Parameters</dt><dd>
418   <table class="params">
419     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
420   </table>
421   </dd>
422 </dl>
423 <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
424 <p>The function <b>osMemoryPoolGetName</b> returns the pointer to the name string of the memory pool identified by parameter <em>mp_id</em> or <span class="XML-Token">NULL</span> in case of an error.</p>
425 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
426
427 </div>
428 </div>
429 <a id="ga8ead54e99ccb8f112356c88f99d38fbe" name="ga8ead54e99ccb8f112356c88f99d38fbe"></a>
430 <h2 class="memtitle"><span class="permalink"><a href="#ga8ead54e99ccb8f112356c88f99d38fbe">&#9670;&#160;</a></span>osMemoryPoolAlloc()</h2>
431
432 <div class="memitem">
433 <div class="memproto">
434       <table class="memname">
435         <tr>
436           <td class="memname">void * osMemoryPoolAlloc </td>
437           <td>(</td>
438           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
439           <td class="paramname"><em>mp_id</em>, </td>
440         </tr>
441         <tr>
442           <td class="paramkey"></td>
443           <td></td>
444           <td class="paramtype">uint32_t&#160;</td>
445           <td class="paramname"><em>timeout</em>&#160;</td>
446         </tr>
447         <tr>
448           <td></td>
449           <td>)</td>
450           <td></td><td></td>
451         </tr>
452       </table>
453 </div><div class="memdoc">
454 <dl class="params"><dt>Parameters</dt><dd>
455   <table class="params">
456     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
457     <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td><a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">Timeout Value</a> or 0 in case of no time-out. </td></tr>
458   </table>
459   </dd>
460 </dl>
461 <dl class="section return"><dt>Returns</dt><dd>address of the allocated memory block or NULL in case of no memory is available.</dd></dl>
462 <p>The blocking function <b>osMemoryPoolAlloc</b> allocates the memory pool parameter <em>mp_id</em> and returns a pointer to the address of the allocated memory or <span class="XML-Token">0</span> in case of an error.</p>
463 <p>The parameter <em>timeout</em> specifies how long the system waits to allocate the memory. While the system waits, the thread that is calling this function is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state. The thread will become <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> as soon as at least one block of memory gets available.</p>
464 <p>The parameter <a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">timeout</a> can have the following values:</p><ul>
465 <li>when <em>timeout</em> is <span class="XML-Token">0</span>, the function returns instantly (i.e. try semantics).</li>
466 <li>when <em>timeout</em> is set to <b>osWaitForever</b> the function will wait for an infinite time until the memory is allocated (i.e. wait semantics).</li>
467 <li>all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).</li>
468 </ul>
469 <p>The result is the pointer to the memory block allocated, or NULL if no memory is available.</p>
470 <dl class="section note"><dt>Note</dt><dd>It is in the responsibility of the user to respect the block size, i.e. not access memory beyond the blocks limit.</dd>
471 <dd>
472 May be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> if the parameter <em>timeout</em> is set to <span class="XML-Token">0</span>.</dd></dl>
473 <p><b>Code</b> <b>Example</b> </p>
474 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
475
476 </div>
477 </div>
478 <a id="gabb4f4560daa6d1f8c8789082ee186d16" name="gabb4f4560daa6d1f8c8789082ee186d16"></a>
479 <h2 class="memtitle"><span class="permalink"><a href="#gabb4f4560daa6d1f8c8789082ee186d16">&#9670;&#160;</a></span>osMemoryPoolFree()</h2>
480
481 <div class="memitem">
482 <div class="memproto">
483       <table class="memname">
484         <tr>
485           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolFree </td>
486           <td>(</td>
487           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
488           <td class="paramname"><em>mp_id</em>, </td>
489         </tr>
490         <tr>
491           <td class="paramkey"></td>
492           <td></td>
493           <td class="paramtype">void *&#160;</td>
494           <td class="paramname"><em>block</em>&#160;</td>
495         </tr>
496         <tr>
497           <td></td>
498           <td>)</td>
499           <td></td><td></td>
500         </tr>
501       </table>
502 </div><div class="memdoc">
503 <dl class="params"><dt>Parameters</dt><dd>
504   <table class="params">
505     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
506     <tr><td class="paramdir">[in]</td><td class="paramname">block</td><td>address of the allocated memory block to be returned to the memory pool. </td></tr>
507   </table>
508   </dd>
509 </dl>
510 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
511 <p>The function <b>osMemoryPoolFree</b> frees the memory pool block specified by the parameter <em>block</em> in the memory pool object specified by the parameter <em>mp_id</em>. The memory block is put back to the list of available blocks.</p>
512 <p>If another thread is waiting for memory to become available the thread is put to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state.</p>
513 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
514 <li><em>osOK:</em> the memory has been freed.</li>
515 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid, <em>block</em> points to invalid memory.</li>
516 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
517 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
518 </ul>
519 <dl class="section note"><dt>Note</dt><dd><b>osMemoryPoolFree</b> may perform certain checks on the <em>block</em> pointer given. But using <b>osMemoryPoolFree</b> with a pointer other than one received from <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a> has <b>UNPREDICTED</b> behaviour.</dd>
520 <dd>
521 This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
522 <p><b>Code</b> <b>Example</b> </p>
523 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
524
525 </div>
526 </div>
527 <a id="gad696e94bfbe28f0b6613f9303fdf6a37" name="gad696e94bfbe28f0b6613f9303fdf6a37"></a>
528 <h2 class="memtitle"><span class="permalink"><a href="#gad696e94bfbe28f0b6613f9303fdf6a37">&#9670;&#160;</a></span>osMemoryPoolGetCapacity()</h2>
529
530 <div class="memitem">
531 <div class="memproto">
532       <table class="memname">
533         <tr>
534           <td class="memname">uint32_t osMemoryPoolGetCapacity </td>
535           <td>(</td>
536           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
537           <td class="paramname"><em>mp_id</em></td><td>)</td>
538           <td></td>
539         </tr>
540       </table>
541 </div><div class="memdoc">
542 <dl class="params"><dt>Parameters</dt><dd>
543   <table class="params">
544     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
545   </table>
546   </dd>
547 </dl>
548 <dl class="section return"><dt>Returns</dt><dd>maximum number of memory blocks.</dd></dl>
549 <p>The function <b>osMemoryPoolGetCapacity</b> returns the maximum number of memory blocks in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
550 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
551
552 </div>
553 </div>
554 <a id="gab2bf059b7fa7679c3cccdaeec60b6c0e" name="gab2bf059b7fa7679c3cccdaeec60b6c0e"></a>
555 <h2 class="memtitle"><span class="permalink"><a href="#gab2bf059b7fa7679c3cccdaeec60b6c0e">&#9670;&#160;</a></span>osMemoryPoolGetBlockSize()</h2>
556
557 <div class="memitem">
558 <div class="memproto">
559       <table class="memname">
560         <tr>
561           <td class="memname">uint32_t osMemoryPoolGetBlockSize </td>
562           <td>(</td>
563           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
564           <td class="paramname"><em>mp_id</em></td><td>)</td>
565           <td></td>
566         </tr>
567       </table>
568 </div><div class="memdoc">
569 <dl class="params"><dt>Parameters</dt><dd>
570   <table class="params">
571     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
572   </table>
573   </dd>
574 </dl>
575 <dl class="section return"><dt>Returns</dt><dd>memory block size in bytes.</dd></dl>
576 <p>The function <b>osMemoryPoolGetBlockSize</b> returns the memory block size in bytes in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
577 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
578
579 </div>
580 </div>
581 <a id="ga958a9449bff8c95ce213de98eef5739d" name="ga958a9449bff8c95ce213de98eef5739d"></a>
582 <h2 class="memtitle"><span class="permalink"><a href="#ga958a9449bff8c95ce213de98eef5739d">&#9670;&#160;</a></span>osMemoryPoolGetCount()</h2>
583
584 <div class="memitem">
585 <div class="memproto">
586       <table class="memname">
587         <tr>
588           <td class="memname">uint32_t osMemoryPoolGetCount </td>
589           <td>(</td>
590           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
591           <td class="paramname"><em>mp_id</em></td><td>)</td>
592           <td></td>
593         </tr>
594       </table>
595 </div><div class="memdoc">
596 <dl class="params"><dt>Parameters</dt><dd>
597   <table class="params">
598     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
599   </table>
600   </dd>
601 </dl>
602 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks used.</dd></dl>
603 <p>The function <b>osMemoryPoolGetCount</b> returns the number of memory blocks used in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
604 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
605
606 </div>
607 </div>
608 <a id="ga0394cffa9479a7994e3b03c79c1cb909" name="ga0394cffa9479a7994e3b03c79c1cb909"></a>
609 <h2 class="memtitle"><span class="permalink"><a href="#ga0394cffa9479a7994e3b03c79c1cb909">&#9670;&#160;</a></span>osMemoryPoolGetSpace()</h2>
610
611 <div class="memitem">
612 <div class="memproto">
613       <table class="memname">
614         <tr>
615           <td class="memname">uint32_t osMemoryPoolGetSpace </td>
616           <td>(</td>
617           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
618           <td class="paramname"><em>mp_id</em></td><td>)</td>
619           <td></td>
620         </tr>
621       </table>
622 </div><div class="memdoc">
623 <dl class="params"><dt>Parameters</dt><dd>
624   <table class="params">
625     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
626   </table>
627   </dd>
628 </dl>
629 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks available.</dd></dl>
630 <p>The function <b>osMemoryPoolGetSpace</b> returns the number of memory blocks available in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
631 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
632
633 </div>
634 </div>
635 <a id="ga8c39e7e5cd2b9eda907466808e59d62e" name="ga8c39e7e5cd2b9eda907466808e59d62e"></a>
636 <h2 class="memtitle"><span class="permalink"><a href="#ga8c39e7e5cd2b9eda907466808e59d62e">&#9670;&#160;</a></span>osMemoryPoolDelete()</h2>
637
638 <div class="memitem">
639 <div class="memproto">
640       <table class="memname">
641         <tr>
642           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolDelete </td>
643           <td>(</td>
644           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
645           <td class="paramname"><em>mp_id</em></td><td>)</td>
646           <td></td>
647         </tr>
648       </table>
649 </div><div class="memdoc">
650 <dl class="params"><dt>Parameters</dt><dd>
651   <table class="params">
652     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
653   </table>
654   </dd>
655 </dl>
656 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
657 <p>The function <b>osMemoryPoolDelete</b> deletes a memory pool object specified by parameter <em>mp_id</em>. It releases internal memory obtained for memory pool handling. After this call, the <em>mp_id</em> is no longer valid and cannot be used. The memory pool may be created again using the function <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>.</p>
658 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
659 <li><em>osOK:</em> the memory pool object has been deleted.</li>
660 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
661 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
662 <li><em>osErrorISR:</em> <b>osMemoryPoolDelete</b> cannot be called from interrupt service routines.</li>
663 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
664 </ul>
665 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
666
667 </div>
668 </div>
669 </div><!-- contents -->
670 </div><!-- doc-content -->
671 <!-- start footer part -->
672 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
673   <ul>
674     <li class="footer">
675       <script type="text/javascript">
676         <!--
677         writeFooter.call(this);
678         //-->
679       </script> 
680     </li>
681   </ul>
682 </div>
683 </body>
684 </html>