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">
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: Thread Management</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&dn=expat.txt MIT */
28 $(document).ready(function() { init_search(); });
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>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
41 <table cellspacing="0" cellpadding="0">
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  <span id="projectnumber"><script type="text/javascript">
49 writeHeader.call(this);
50 writeVersionDropdown.call(this, "CMSIS-RTOS2");
55 <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div>
57 <td> <div id="MSearchBox" class="MSearchBoxInactive">
59 <span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </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>
69 <!--END !PROJECT_NAME-->
74 <!-- end header part -->
75 <div id="CMSISnav" class="tabs1">
77 <script type="text/javascript">
78 writeComponentTabs.call(this);
82 <!-- Generated by Doxygen 1.9.6 -->
83 <script type="text/javascript">
84 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
85 var searchBox = new SearchBox("searchBox", "search/",'.html');
89 <div id="side-nav" class="ui-resizable side-nav-resizable">
91 <div id="nav-tree-contents">
92 <div id="nav-sync" class="sync"></div>
95 <div id="splitbar" style="-moz-user-select:none;"
96 class="ui-resizable-handle">
99 <script type="text/javascript">
100 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
101 $(document).ready(function(){initNavTree('group__CMSIS__RTOS__ThreadMgmt.html',''); initResizable(); });
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)">
112 <!-- iframe showing the search results (closed by default) -->
113 <div id="MSearchResultsWindow">
114 <div id="MSearchResults">
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>
127 <div class="summary">
128 <a href="#nested-classes">Data Structures</a> |
129 <a href="#define-members">Macros</a> |
130 <a href="#typedef-members">Typedefs</a> |
131 <a href="#enum-members">Enumerations</a> |
132 <a href="#enumval-members">Enumerator</a> |
133 <a href="#func-members">Functions</a> </div>
134 <div class="headertitle"><div class="title">Thread Management<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div></div>
136 <div class="contents">
138 <p>Define, create, and control thread functions.
139 <a href="#details">More...</a></p>
140 <table class="memberdecls">
141 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
142 Data Structures</h2></td></tr>
143 <tr class="memitem:structosThreadAttr__t"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a></td></tr>
144 <tr class="memdesc:structosThreadAttr__t"><td class="mdescLeft"> </td><td class="mdescRight">Attributes structure for thread. <a href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">More...</a><br /></td></tr>
145 <tr class="separator:structosThreadAttr__t"><td class="memSeparator" colspan="2"> </td></tr>
146 </table><table class="memberdecls">
147 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
148 Macros</h2></td></tr>
149 <tr class="memitem:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>   0x00000001U</td></tr>
150 <tr class="memdesc:ga249499c519f3f8eef5673009ab6cfcbe"><td class="mdescLeft"> </td><td class="mdescRight">Thread created in joinable mode. <br /></td></tr>
151 <tr class="separator:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memSeparator" colspan="2"> </td></tr>
152 <tr class="memitem:gaa9336c1073858d6b118e2e011636246f"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>   0x00000000U</td></tr>
153 <tr class="memdesc:gaa9336c1073858d6b118e2e011636246f"><td class="mdescLeft"> </td><td class="mdescRight">Thread created in detached mode (default) <br /></td></tr>
154 <tr class="separator:gaa9336c1073858d6b118e2e011636246f"><td class="memSeparator" colspan="2"> </td></tr>
155 <tr class="memitem:ga4c028e5c3f4d86d237a1e09ceaf84792"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga4c028e5c3f4d86d237a1e09ceaf84792">osThreadUnprivileged</a>   0x00000002U</td></tr>
156 <tr class="memdesc:ga4c028e5c3f4d86d237a1e09ceaf84792"><td class="mdescLeft"> </td><td class="mdescRight">Thread runs in unprivileged mode. <br /></td></tr>
157 <tr class="separator:ga4c028e5c3f4d86d237a1e09ceaf84792"><td class="memSeparator" colspan="2"> </td></tr>
158 <tr class="memitem:ga7c2b7db42d23e4f56132e0ed739d02e5"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga7c2b7db42d23e4f56132e0ed739d02e5">osThreadPrivileged</a>   0x00000004U</td></tr>
159 <tr class="memdesc:ga7c2b7db42d23e4f56132e0ed739d02e5"><td class="mdescLeft"> </td><td class="mdescRight">Thread runs in privileged mode. <br /></td></tr>
160 <tr class="separator:ga7c2b7db42d23e4f56132e0ed739d02e5"><td class="memSeparator" colspan="2"> </td></tr>
161 <tr class="memitem:gaefca370070d0b1616421bc3311acfecc"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaefca370070d0b1616421bc3311acfecc">osThreadZone</a>(n)</td></tr>
162 <tr class="memdesc:gaefca370070d0b1616421bc3311acfecc"><td class="mdescLeft"> </td><td class="mdescRight">MPU zone value in attribute bit field format. <br /></td></tr>
163 <tr class="separator:gaefca370070d0b1616421bc3311acfecc"><td class="memSeparator" colspan="2"> </td></tr>
164 </table><table class="memberdecls">
165 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
166 Typedefs</h2></td></tr>
167 <tr class="memitem:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memItemLeft" align="right" valign="top">typedef void(* </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a>) (void *argument)</td></tr>
168 <tr class="memdesc:gadd51f99a6eb50b94eee75f27cae815eb"><td class="mdescLeft"> </td><td class="mdescRight">Entry point of a thread. <br /></td></tr>
169 <tr class="separator:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memSeparator" colspan="2"> </td></tr>
170 <tr class="memitem:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memItemLeft" align="right" valign="top">typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td></tr>
171 <tr class="separator:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memSeparator" colspan="2"> </td></tr>
172 </table><table class="memberdecls">
173 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
174 Enumerations</h2></td></tr>
175 <tr class="memitem:gad3dc89e942e38d9f3af858a0269a820d"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> { <br />
176   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dae9d77830b6866e287417b6e1d983e971">osThreadInactive</a> = 0
178   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da59e286915944fe0e4d1ffdb1f2946f14">osThreadReady</a> = 1
180   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dac4fe336e0790188fcf7d667372eca19d">osThreadRunning</a> = 2
182   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968">osThreadBlocked</a> = 3
184   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c">osThreadTerminated</a> = 4
186   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a> = -1
188   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c">osThreadReserved</a> = 0x7FFFFFFF
191 <tr class="memdesc:gad3dc89e942e38d9f3af858a0269a820d"><td class="mdescLeft"> </td><td class="mdescRight">Thread state. <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">More...</a><br /></td></tr>
192 <tr class="separator:gad3dc89e942e38d9f3af858a0269a820d"><td class="memSeparator" colspan="2"> </td></tr>
193 <tr class="memitem:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> { <br />
194   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3">osPriorityNone</a> = 0
196   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad4e3e0971b41f2d17584a8c6837342ecacd5864eac01a6916a7c866bb51a6aac1">osPriorityIdle</a> = 1
198   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4">osPriorityLow</a> = 8
200   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe">osPriorityLow1</a> = 8+1
202   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507">osPriorityLow2</a> = 8+2
204   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50">osPriorityLow3</a> = 8+3
206   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81">osPriorityLow4</a> = 8+4
208   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353">osPriorityLow5</a> = 8+5
210   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393">osPriorityLow6</a> = 8+6
212   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a">osPriorityLow7</a> = 8+7
214   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a> = 16
216   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5">osPriorityBelowNormal1</a> = 16+1
218   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3">osPriorityBelowNormal2</a> = 16+2
220   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf">osPriorityBelowNormal3</a> = 16+3
222   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24">osPriorityBelowNormal4</a> = 16+4
224   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e">osPriorityBelowNormal5</a> = 16+5
226   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05">osPriorityBelowNormal6</a> = 16+6
228   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b">osPriorityBelowNormal7</a> = 16+7
230   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1">osPriorityNormal</a> = 24
232   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c">osPriorityNormal1</a> = 24+1
234   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205">osPriorityNormal2</a> = 24+2
236   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91">osPriorityNormal3</a> = 24+3
238   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d">osPriorityNormal4</a> = 24+4
240   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab">osPriorityNormal5</a> = 24+5
242   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204">osPriorityNormal6</a> = 24+6
244   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b">osPriorityNormal7</a> = 24+7
246   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a> = 32
248   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998">osPriorityAboveNormal1</a> = 32+1
250   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562">osPriorityAboveNormal2</a> = 32+2
252   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013">osPriorityAboveNormal3</a> = 32+3
254   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec">osPriorityAboveNormal4</a> = 32+4
256   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c">osPriorityAboveNormal5</a> = 32+5
258   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207">osPriorityAboveNormal6</a> = 32+6
260   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d">osPriorityAboveNormal7</a> = 32+7
262   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a> = 40
264   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb">osPriorityHigh1</a> = 40+1
266   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03">osPriorityHigh2</a> = 40+2
268   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759">osPriorityHigh3</a> = 40+3
270   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb">osPriorityHigh4</a> = 40+4
272   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9">osPriorityHigh5</a> = 40+5
274   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc">osPriorityHigh6</a> = 40+6
276   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652">osPriorityHigh7</a> = 40+7
278   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af">osPriorityRealtime</a> = 48
280   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b">osPriorityRealtime1</a> = 48+1
282   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff">osPriorityRealtime2</a> = 48+2
284   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa">osPriorityRealtime3</a> = 48+3
286   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70">osPriorityRealtime4</a> = 48+4
288   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df">osPriorityRealtime5</a> = 48+5
290   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194">osPriorityRealtime6</a> = 48+6
292   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b">osPriorityRealtime7</a> = 48+7
294   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad4e3e0971b41f2d17584a8c6837342eca4b4fa46c3ebaf4259662a0a0a3173b7f">osPriorityISR</a> = 56
296   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4">osPriorityError</a> = -1
298   <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b">osPriorityReserved</a> = 0x7FFFFFFF
301 <tr class="memdesc:gad4e3e0971b41f2d17584a8c6837342ec"><td class="mdescLeft"> </td><td class="mdescRight">Priority values. <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">More...</a><br /></td></tr>
302 <tr class="separator:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memSeparator" colspan="2"> </td></tr>
303 </table><table class="memberdecls">
304 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
305 Functions</h2></td></tr>
306 <tr class="memitem:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a> func, void *argument, const <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *attr)</td></tr>
307 <tr class="memdesc:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="mdescLeft"> </td><td class="mdescRight">Create a thread and add it to Active Threads. <br /></td></tr>
308 <tr class="separator:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memSeparator" colspan="2"> </td></tr>
309 <tr class="memitem:gac3230f3a55a297514b013ebf38f27e0a"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
310 <tr class="memdesc:gac3230f3a55a297514b013ebf38f27e0a"><td class="mdescLeft"> </td><td class="mdescRight">Get name of a thread. <br /></td></tr>
311 <tr class="separator:gac3230f3a55a297514b013ebf38f27e0a"><td class="memSeparator" colspan="2"> </td></tr>
312 <tr class="memitem:ga1bfbef7da94ed4147d231e8d6eeb5f3e"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga1bfbef7da94ed4147d231e8d6eeb5f3e">osThreadGetClass</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
313 <tr class="memdesc:ga1bfbef7da94ed4147d231e8d6eeb5f3e"><td class="mdescLeft"> </td><td class="mdescRight">Get safety class of a thread. <br /></td></tr>
314 <tr class="separator:ga1bfbef7da94ed4147d231e8d6eeb5f3e"><td class="memSeparator" colspan="2"> </td></tr>
315 <tr class="memitem:ga4101737fa4fd303d4b41fdca6b994f8e"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga4101737fa4fd303d4b41fdca6b994f8e">osThreadGetZone</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
316 <tr class="memdesc:ga4101737fa4fd303d4b41fdca6b994f8e"><td class="mdescLeft"> </td><td class="mdescRight">Get MPU protected zone of a thread. <br /></td></tr>
317 <tr class="separator:ga4101737fa4fd303d4b41fdca6b994f8e"><td class="memSeparator" colspan="2"> </td></tr>
318 <tr class="memitem:ga8df03548e89fbc56402a5cd584a505da"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> (void)</td></tr>
319 <tr class="memdesc:ga8df03548e89fbc56402a5cd584a505da"><td class="mdescLeft"> </td><td class="mdescRight">Return the thread ID of the current running thread. <br /></td></tr>
320 <tr class="separator:ga8df03548e89fbc56402a5cd584a505da"><td class="memSeparator" colspan="2"> </td></tr>
321 <tr class="memitem:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
322 <tr class="memdesc:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="mdescLeft"> </td><td class="mdescRight">Get current thread state of a thread. <br /></td></tr>
323 <tr class="separator:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memSeparator" colspan="2"> </td></tr>
324 <tr class="memitem:ga861a420fb2d643115b06622903fb3bfb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> priority)</td></tr>
325 <tr class="memdesc:ga861a420fb2d643115b06622903fb3bfb"><td class="mdescLeft"> </td><td class="mdescRight">Change priority of a thread. <br /></td></tr>
326 <tr class="separator:ga861a420fb2d643115b06622903fb3bfb"><td class="memSeparator" colspan="2"> </td></tr>
327 <tr class="memitem:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
328 <tr class="memdesc:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="mdescLeft"> </td><td class="mdescRight">Get current priority of a thread. <br /></td></tr>
329 <tr class="separator:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memSeparator" colspan="2"> </td></tr>
330 <tr class="memitem:gad01c7ec26535b1de6b018bb9466720e2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (void)</td></tr>
331 <tr class="memdesc:gad01c7ec26535b1de6b018bb9466720e2"><td class="mdescLeft"> </td><td class="mdescRight">Pass control to next thread that is in state <b>READY</b>. <br /></td></tr>
332 <tr class="separator:gad01c7ec26535b1de6b018bb9466720e2"><td class="memSeparator" colspan="2"> </td></tr>
333 <tr class="memitem:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
334 <tr class="memdesc:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="mdescLeft"> </td><td class="mdescRight">Suspend execution of a thread. <br /></td></tr>
335 <tr class="separator:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memSeparator" colspan="2"> </td></tr>
336 <tr class="memitem:ga3dbad90eff394b02de76a452c84c5d80"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
337 <tr class="memdesc:ga3dbad90eff394b02de76a452c84c5d80"><td class="mdescLeft"> </td><td class="mdescRight">Resume execution of a thread. <br /></td></tr>
338 <tr class="separator:ga3dbad90eff394b02de76a452c84c5d80"><td class="memSeparator" colspan="2"> </td></tr>
339 <tr class="memitem:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaaad14cd9547341ea8109dc4e8540f1dc">osThreadDetach</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
340 <tr class="memdesc:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="mdescLeft"> </td><td class="mdescRight">Detach a thread (thread storage can be reclaimed when thread terminates). <br /></td></tr>
341 <tr class="separator:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memSeparator" colspan="2"> </td></tr>
342 <tr class="memitem:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
343 <tr class="memdesc:ga3fca90fb0679afeb968aa8c3d5874487"><td class="mdescLeft"> </td><td class="mdescRight">Wait for specified thread to terminate. <br /></td></tr>
344 <tr class="separator:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memSeparator" colspan="2"> </td></tr>
345 <tr class="memitem:gaddaa452dd7610e4096647a566d3556fc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a> (void)</td></tr>
346 <tr class="memdesc:gaddaa452dd7610e4096647a566d3556fc"><td class="mdescLeft"> </td><td class="mdescRight">Terminate execution of current running thread. <br /></td></tr>
347 <tr class="separator:gaddaa452dd7610e4096647a566d3556fc"><td class="memSeparator" colspan="2"> </td></tr>
348 <tr class="memitem:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
349 <tr class="memdesc:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="mdescLeft"> </td><td class="mdescRight">Terminate execution of a thread. <br /></td></tr>
350 <tr class="separator:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memSeparator" colspan="2"> </td></tr>
351 <tr class="memitem:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gab9f8bd715d671c6ee27644867bc1bf65">osThreadGetStackSize</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
352 <tr class="memdesc:gab9f8bd715d671c6ee27644867bc1bf65"><td class="mdescLeft"> </td><td class="mdescRight">Get stack size of a thread. <br /></td></tr>
353 <tr class="separator:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memSeparator" colspan="2"> </td></tr>
354 <tr class="memitem:ga9c83bd5dd8de329701775d6ef7012720"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga9c83bd5dd8de329701775d6ef7012720">osThreadGetStackSpace</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
355 <tr class="memdesc:ga9c83bd5dd8de329701775d6ef7012720"><td class="mdescLeft"> </td><td class="mdescRight">Get available stack space of a thread based on stack watermark recording during execution. <br /></td></tr>
356 <tr class="separator:ga9c83bd5dd8de329701775d6ef7012720"><td class="memSeparator" colspan="2"> </td></tr>
357 <tr class="memitem:ga495b3f812224e7301f23a691793765db"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga495b3f812224e7301f23a691793765db">osThreadGetCount</a> (void)</td></tr>
358 <tr class="memdesc:ga495b3f812224e7301f23a691793765db"><td class="mdescLeft"> </td><td class="mdescRight">Get number of active threads. <br /></td></tr>
359 <tr class="separator:ga495b3f812224e7301f23a691793765db"><td class="memSeparator" colspan="2"> </td></tr>
360 <tr class="memitem:ga5606604d56e21ece1a654664be877439"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5606604d56e21ece1a654664be877439">osThreadEnumerate</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> *thread_array, uint32_t array_items)</td></tr>
361 <tr class="memdesc:ga5606604d56e21ece1a654664be877439"><td class="mdescLeft"> </td><td class="mdescRight">Enumerate active threads. <br /></td></tr>
362 <tr class="separator:ga5606604d56e21ece1a654664be877439"><td class="memSeparator" colspan="2"> </td></tr>
363 <tr class="memitem:ga8f4455b06afb95c1915f15266818a8c6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8f4455b06afb95c1915f15266818a8c6">osThreadFeedWatchdog</a> (uint32_t ticks)</td></tr>
364 <tr class="memdesc:ga8f4455b06afb95c1915f15266818a8c6"><td class="mdescLeft"> </td><td class="mdescRight">Feed watchdog of the current running thread. <br /></td></tr>
365 <tr class="separator:ga8f4455b06afb95c1915f15266818a8c6"><td class="memSeparator" colspan="2"> </td></tr>
366 <tr class="memitem:gaee8e6bed82cd58dad31bb90156182032"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee8e6bed82cd58dad31bb90156182032">osThreadProtectPrivileged</a> (void)</td></tr>
367 <tr class="memdesc:gaee8e6bed82cd58dad31bb90156182032"><td class="mdescLeft"> </td><td class="mdescRight">Protect creation of privileged threads. <br /></td></tr>
368 <tr class="separator:gaee8e6bed82cd58dad31bb90156182032"><td class="memSeparator" colspan="2"> </td></tr>
369 <tr class="memitem:gadadb56627094dbb07f6aeddf7d713fd9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadadb56627094dbb07f6aeddf7d713fd9">osThreadSuspendClass</a> (uint32_t safety_class, uint32_t mode)</td></tr>
370 <tr class="memdesc:gadadb56627094dbb07f6aeddf7d713fd9"><td class="mdescLeft"> </td><td class="mdescRight">Suspend execution of threads for specified safety classes. <br /></td></tr>
371 <tr class="separator:gadadb56627094dbb07f6aeddf7d713fd9"><td class="memSeparator" colspan="2"> </td></tr>
372 <tr class="memitem:gadd0a06b459925eb5cdeab67b380a3970"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd0a06b459925eb5cdeab67b380a3970">osThreadResumeClass</a> (uint32_t safety_class, uint32_t mode)</td></tr>
373 <tr class="memdesc:gadd0a06b459925eb5cdeab67b380a3970"><td class="mdescLeft"> </td><td class="mdescRight">Resume execution of threads for specified safety classes. <br /></td></tr>
374 <tr class="separator:gadd0a06b459925eb5cdeab67b380a3970"><td class="memSeparator" colspan="2"> </td></tr>
375 <tr class="memitem:ga99ce311cc620c65fbac043d04dc7d755"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga99ce311cc620c65fbac043d04dc7d755">osThreadTerminateZone</a> (uint32_t zone)</td></tr>
376 <tr class="memdesc:ga99ce311cc620c65fbac043d04dc7d755"><td class="mdescLeft"> </td><td class="mdescRight">Terminate execution of threads assigned to a specified MPU protected zone. <br /></td></tr>
377 <tr class="separator:ga99ce311cc620c65fbac043d04dc7d755"><td class="memSeparator" colspan="2"> </td></tr>
378 <tr class="memitem:ga5a02770aaf65c7a3c7562c109884176a"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
379 <tr class="memdesc:ga5a02770aaf65c7a3c7562c109884176a"><td class="mdescLeft"> </td><td class="mdescRight">Handler for expired thread watchdogs. <br /></td></tr>
380 <tr class="separator:ga5a02770aaf65c7a3c7562c109884176a"><td class="memSeparator" colspan="2"> </td></tr>
381 <tr class="memitem:ga79d4b26de0bfcdaf142f83e585532f93"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga79d4b26de0bfcdaf142f83e585532f93">osZoneSetup_Callback</a> (uint32_t zone)</td></tr>
382 <tr class="memdesc:ga79d4b26de0bfcdaf142f83e585532f93"><td class="mdescLeft"> </td><td class="mdescRight">Setup MPU protected zone (called when zone changes). <br /></td></tr>
383 <tr class="separator:ga79d4b26de0bfcdaf142f83e585532f93"><td class="memSeparator" colspan="2"> </td></tr>
385 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
386 <p>The Thread Management function group allows defining, creating, and controlling thread functions in the system.</p>
387 <dl class="section note"><dt>Note</dt><dd>Thread management functions cannot be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
388 <p><a class="anchor" id="ThreadStates"></a></p>
389 <h2><a class="anchor" id="autotoc_md1"></a>
391 <p>Threads can be in the following states:</p>
393 <li><b>RUNNING:</b> The thread that is currently running is in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> state. Only one thread at a time can be in this state.</li>
394 <li><b>READY:</b> Threads which are ready to run are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. Once the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread has terminated, or is <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a>, the next <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread with the highest priority becomes the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread.</li>
395 <li><b>BLOCKED:</b> Threads that are blocked either delayed, waiting for an event to occur or suspended are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state.</li>
396 <li><b>TERMINATED:</b> When <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> is called, threads are <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">TERMINATED</a> with resources not yet released (applies to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable threads).</a></li>
397 <li><b>INACTIVE:</b> Threads that are not created or have been terminated with all resources released are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">INACTIVE</a> state.</li>
400 <img src="ThreadStatus.png" alt=""/>
401 <div class="caption">
402 Thread State and State Transitions</div></div>
403 <p>A CMSIS-RTOS assumes that threads are scheduled as shown in the figure <b>Thread State and State Transitions</b>. The thread states change as follows:</p><ul>
404 <li>A thread is created using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>. This puts the thread into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> state (depending on the thread priority).</li>
405 <li>CMSIS-RTOS is preemptive. The active thread with the highest priority becomes the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread provided it does not wait for any event. The initial priority of a thread is defined with the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> but may be changed during execution using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a>.</li>
406 <li>The <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread transfers into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state when it is delayed, waiting for an event or suspended.</li>
407 <li>Active threads can be terminated any time using the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a>. Threads can terminate also by just returning from the thread function. Threads that are terminated are in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">INACTIVE</a> state and typically do not consume any dynamic memory resources.</li>
409 <dl class="section note"><dt>Note</dt><dd>Refer to <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a> for RTX5 configuration options.</dd></dl>
410 <p><a class="anchor" id="thread_examples"></a></p>
411 <h1><a class="anchor" id="autotoc_md2"></a>
413 <p>The following examples show various scenarios to create threads:</p>
414 <p><b>Example 1 - Create a simple thread</b></p>
415 <p>Create a thread out of the function thread1 using all default values for thread attributes and memory from the <a class="el" href="theory_of_operation.html#GlobalMemoryPool">Global Memory Pool</a>.</p>
416 <div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
417 <div class="line"> <span class="comment">// ...</span></div>
418 <div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
419 <div class="line">}</div>
420 <div class="line"> </div>
421 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
422 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>();</div>
423 <div class="line"> ;</div>
424 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, NULL); <span class="comment">// Create thread with default settings</span></div>
425 <div class="line"> ;</div>
426 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>(); </div>
427 <div class="line">}</div>
428 <div class="ttc" id="acmsis__os2_8h_html_a153a4a31b276a9758959580538720a51"><div class="ttname"><a href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a></div><div class="ttdeci">#define __NO_RETURN</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:76</div></div>
429 <div class="ttc" id="agroup__CMSIS__RTOS__KernelCtrl_html_ga9ae2cc00f0d89d7b6a307bba942b5221"><div class="ttname"><a href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a></div><div class="ttdeci">osStatus_t osKernelStart(void)</div><div class="ttdoc">Start the RTOS Kernel scheduler.</div></div>
430 <div class="ttc" id="agroup__CMSIS__RTOS__KernelCtrl_html_gae818f6611d25ba3140bede410a52d659"><div class="ttname"><a href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a></div><div class="ttdeci">osStatus_t osKernelInitialize(void)</div><div class="ttdoc">Initialize the RTOS Kernel.</div></div>
431 <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>
432 </div><!-- fragment --><p><b>Example 2 - Create thread with stack non-default stack size</b></p>
433 <p>Similar to the simple thread all attributes are default. The stack is dynamically allocated from the <a class="el" href="theory_of_operation.html#GlobalMemoryPool">Global Memory Pool</a></p>
434 <p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">osThreadAttr_t::stack_size</a> is used to pass the stack size in Bytes to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>.</p>
435 <div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
436 <div class="line"> <span class="comment">// ...</span></div>
437 <div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
438 <div class="line">}</div>
439 <div class="line"> </div>
440 <div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
441 <div class="line"> .<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">stack_size</a> = 1024 <span class="comment">// Create the thread stack with a size of 1024 bytes</span></div>
442 <div class="line">};</div>
443 <div class="line"> </div>
444 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
445 <div class="line"> ; </div>
446 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &thread1_attr); <span class="comment">// Create thread with custom sized stack memory</span></div>
447 <div class="line"> ;</div>
448 <div class="line">}</div>
449 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_aacbc9a219f2d6870e9ce89bb93f975c9"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">osThreadAttr_t::stack_size</a></div><div class="ttdeci">uint32_t stack_size</div><div class="ttdoc">size of stack</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:288</div></div>
450 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_structosThreadAttr__t"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a></div><div class="ttdoc">Attributes structure for thread.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:282</div></div>
451 </div><!-- fragment --><p><b>Example 3 - Create thread with statically allocated stack</b></p>
452 <p>Similar to the simple thread all attributes are default. The stack is statically allocated using the <code>uint64_t</code> array <code>thread1_stk_1</code>. This allocates 64*8 Bytes (=512 Bytes) with an alignment of 8 Bytes (mandatory for Cortex-M stack memory).</p>
453 <p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">osThreadAttr_t::stack_mem</a> holds a pointer to the stacks lowest address.</p>
454 <p><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#aacbc9a219f2d6870e9ce89bb93f975c9">osThreadAttr_t::stack_size</a> is used to pass the stack size in Bytes to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>.</p>
455 <div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
456 <div class="line"> <span class="comment">// ...</span></div>
457 <div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
458 <div class="line">}</div>
459 <div class="line"> </div>
460 <div class="line"><span class="keyword">static</span> uint64_t thread1_stk_1[64];</div>
461 <div class="line"> </div>
462 <div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
463 <div class="line"> .<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a> = &thread1_stk_1[0],</div>
464 <div class="line"> .stack_size = <span class="keyword">sizeof</span>(thread1_stk_1)</div>
465 <div class="line">};</div>
466 <div class="line"> </div>
467 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
468 <div class="line"> ; </div>
469 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &thread1_attr); <span class="comment">// Create thread with statically allocated stack memory</span></div>
470 <div class="line"> ;</div>
471 <div class="line">}</div>
472 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ad7c9b42355a4c8b9467130ab3fb19e43"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">osThreadAttr_t::stack_mem</a></div><div class="ttdeci">void * stack_mem</div><div class="ttdoc">memory for stack</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:287</div></div>
473 </div><!-- fragment --><p><b>Example 4 - Thread with statically allocated task control block</b></p>
474 <p>Typically this method is chosen together with a statically allocated stack as shown in Example 2. </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
475 <div class="line"> </div>
476 <div class="line"><span class="comment">//include rtx_os.h for types of RTX objects</span></div>
477 <div class="line"><span class="preprocessor">#include "rtx_os.h"</span></div>
478 <div class="line"> </div>
479 <div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
480 <div class="line"> <span class="comment">// ...</span></div>
481 <div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
482 <div class="line">}</div>
483 <div class="line"> </div>
484 <div class="line"><span class="keyword">static</span> osRtxThread_t thread1_tcb;</div>
485 <div class="line"> </div>
486 <div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
487 <div class="line"> .<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a> = &thread1_tcb,</div>
488 <div class="line"> .cb_size = <span class="keyword">sizeof</span>(thread1_tcb),</div>
489 <div class="line">};</div>
490 <div class="line"> </div>
491 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
492 <div class="line"> ;</div>
493 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &thread1_attr); <span class="comment">// Create thread with custom tcb memory</span></div>
494 <div class="line"> ;</div>
495 <div class="line">}</div>
496 <div class="ttc" id="acmsis__os2_8h_html"><div class="ttname"><a href="cmsis__os2_8h.html">cmsis_os2.h</a></div></div>
497 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_a1e100dc33d403841ed3c344e3397868e"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">osThreadAttr_t::cb_mem</a></div><div class="ttdeci">void * cb_mem</div><div class="ttdoc">memory for control block</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:285</div></div>
498 </div><!-- fragment --><p><b>Example 5 - Create thread with a different priority</b></p>
499 <p>The default priority of RTX is <a class="el" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1">osPriorityNormal</a>. Often you want to run a task with a higher or lower priority. Using the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> control structure you can set any initial priority required.</p>
500 <div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
501 <div class="line"> <span class="comment">// ...</span></div>
502 <div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
503 <div class="line">}</div>
504 <div class="line"> </div>
505 <div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
506 <div class="line"> .<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#a6a5183df4c54c3e28dc8dc704f2487d5">priority</a> = <a class="code hl_enumvalue" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a> <span class="comment">//Set initial thread priority to high </span></div>
507 <div class="line">};</div>
508 <div class="line"> </div>
509 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
510 <div class="line"> ;</div>
511 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &thread1_attr);</div>
512 <div class="line"> ;</div>
513 <div class="line">}</div>
514 <div class="ttc" id="acmsis__os2_8h_html_gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2"><div class="ttname"><a href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a></div><div class="ttdeci">@ osPriorityHigh</div><div class="ttdoc">Priority: high.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:155</div></div>
515 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_a6a5183df4c54c3e28dc8dc704f2487d5"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#a6a5183df4c54c3e28dc8dc704f2487d5">osThreadAttr_t::priority</a></div><div class="ttdeci">osPriority_t priority</div><div class="ttdoc">initial thread priority (default: osPriorityNormal)</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:289</div></div>
516 </div><!-- fragment --><p><a class="anchor" id="joinable_threads"></a><b>Example 6 - Joinable threads</b></p>
517 <p>In this example a master thread creates four threads with the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a> attribute. These will do some work and return using the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a> call after finished. <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> is used to synchronize the thread termination.</p>
518 <div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) {</div>
519 <div class="line"> ; <span class="comment">// work a lot on data[] </span></div>
520 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000U);</div>
521 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
522 <div class="line">}</div>
523 <div class="line"> </div>
524 <div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
525 <div class="line"> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> worker_attr;</div>
526 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> worker_ids[4];</div>
527 <div class="line"> uint8_t data[4][10];</div>
528 <div class="line"> </div>
529 <div class="line"> memset(&worker_attr, 0, <span class="keyword">sizeof</span>(worker_attr));</div>
530 <div class="line"> worker_attr.<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#a6e93b49cb79c12f768d72580c7731f30">attr_bits</a> = <a class="code hl_define" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>;</div>
531 <div class="line"> </div>
532 <div class="line"> worker_ids[0] = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &data[0][0], &worker_attr);</div>
533 <div class="line"> worker_ids[1] = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &data[1][0], &worker_attr);</div>
534 <div class="line"> worker_ids[2] = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &data[2][0], &worker_attr);</div>
535 <div class="line"> worker_ids[3] = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &data[3][0], &worker_attr);</div>
536 <div class="line"> </div>
537 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[0]);</div>
538 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[1]);</div>
539 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[2]);</div>
540 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[3]);</div>
541 <div class="line"> </div>
542 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>(); </div>
543 <div class="line">}</div>
544 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_a6e93b49cb79c12f768d72580c7731f30"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#a6e93b49cb79c12f768d72580c7731f30">osThreadAttr_t::attr_bits</a></div><div class="ttdeci">uint32_t attr_bits</div><div class="ttdoc">attribute bits</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:284</div></div>
545 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga249499c519f3f8eef5673009ab6cfcbe"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a></div><div class="ttdeci">#define osThreadJoinable</div><div class="ttdoc">Thread created in joinable mode.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:207</div></div>
546 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga3fca90fb0679afeb968aa8c3d5874487"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a></div><div class="ttdeci">osStatus_t osThreadJoin(osThreadId_t thread_id)</div><div class="ttdoc">Wait for specified thread to terminate.</div></div>
547 <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>
548 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gaddaa452dd7610e4096647a566d3556fc"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a></div><div class="ttdeci">__NO_RETURN void osThreadExit(void)</div><div class="ttdoc">Terminate execution of current running thread.</div></div>
549 <div class="ttc" id="agroup__CMSIS__RTOS__Wait_html_gaf6055a51390ef65b6b6edc28bf47322e"><div class="ttname"><a href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a></div><div class="ttdeci">osStatus_t osDelay(uint32_t ticks)</div><div class="ttdoc">Wait for Timeout (Time Delay).</div></div>
550 </div><!-- fragment --> <hr/><h2 class="groupheader">Data Structure Documentation</h2>
551 <a name="structosThreadAttr__t" id="structosThreadAttr__t"></a>
552 <h2 class="memtitle"><span class="permalink"><a href="#structosThreadAttr__t">◆ </a></span>osThreadAttr_t</h2>
554 <div class="memitem">
555 <div class="memproto">
556 <table class="memname">
558 <td class="memname">struct osThreadAttr_t</td>
561 </div><div class="memdoc">
562 <div class="textblock"><p>Specifies the following attributes for the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function. </p>
563 </div><table class="fieldtable">
564 <tr><th colspan="3">Data Fields</th></tr>
565 <tr><td class="fieldtype">
566 <a id="ab74e6bf80237ddc4109968cedc58c151" name="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
567 <td class="fieldname">
569 <td class="fielddoc">
570 name of the thread <p>Pointer to a constant string with a human readable name (displayed during debugging) of the thread object.</p>
571 <p>Default: <span class="XML-Token">NULL</span> no name specified (debugger may display function name instead). </p>
573 <tr><td class="fieldtype">
574 <a id="a6e93b49cb79c12f768d72580c7731f30" name="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
575 <td class="fieldname">
577 <td class="fielddoc">
578 attribute bits <p>The following bit masks can be used to set options:</p><ul>
579 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a> : create thread in a detached mode (default).</li>
580 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a> : create thread in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable mode</a>. <br />
582 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga4c028e5c3f4d86d237a1e09ceaf84792">osThreadUnprivileged</a> : create thread to execute in unprivileged mode.</li>
583 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga7c2b7db42d23e4f56132e0ed739d02e5">osThreadPrivileged</a> : create thread to execute in privileged mode. <br />
585 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaefca370070d0b1616421bc3311acfecc">osThreadZone</a> (m) : create thread assigned to MPU zone <span class="XML-Token">m</span>.</li>
586 <li><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga604fce4f5205f92c347eb62fcc216861">osSafetyClass</a> (n) : create thread with safety class <span class="XML-Token">n</span> assigned to it.</li>
588 <p>Default: <span class="XML-Token">0</span> no options set. Safety class and MPU Zone are inherited from running thread. Thread privilege mode is set based on configuration <a class="el" href="config_rtx5.html#threadConfig_procmode">Processor Mode for Thread Execution</a>. </p>
590 <tr><td class="fieldtype">
591 <a id="a1e100dc33d403841ed3c344e3397868e" name="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
592 <td class="fieldname">
594 <td class="fielddoc">
595 memory for control block <p>Pointer to a memory for the thread control block object. Refer to <a class="el" href="theory_of_operation.html#StaticObjectMemory">Static Object Memory</a> for more information.</p>
596 <p>Default: <span class="XML-Token">NULL</span> to use <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html#CMSIS_RTOS_MemoryMgmt_Automatic">Automatic Dynamic Allocation</a> for the thread control block. </p>
598 <tr><td class="fieldtype">
599 <a id="aa55a4335d12dc2785dc00fdc292d1159" name="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
600 <td class="fieldname">
602 <td class="fielddoc">
603 size of provided memory for control block <p>The size (in bytes) of memory block passed with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. For RTX, the minimum value is defined with osRtxThreadCbSize (higher values are permitted).</p>
604 <p>Default: <span class="XML-Token">0</span> as the default is no memory provided with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. </p>
606 <tr><td class="fieldtype">
607 <a id="ad7c9b42355a4c8b9467130ab3fb19e43" name="ad7c9b42355a4c8b9467130ab3fb19e43"></a>void *</td>
608 <td class="fieldname">
610 <td class="fielddoc">
611 memory for stack <p>Pointer to a memory location for the thread stack (64-bit aligned).</p>
612 <p>Default: <span class="XML-Token">NULL</span> to allocate stack from a fixed-size memory pool using <a class="el" href="theory_of_operation.html#ThreadStack">Thread Stack Management</a>. </p>
614 <tr><td class="fieldtype">
615 <a id="aacbc9a219f2d6870e9ce89bb93f975c9" name="aacbc9a219f2d6870e9ce89bb93f975c9"></a>uint32_t</td>
616 <td class="fieldname">
618 <td class="fielddoc">
619 size of stack <p>The size (in bytes) of the stack specified by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a>.</p>
620 <p>Default: <span class="XML-Token">0</span> as the default is no memory provided with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a>. </p>
622 <tr><td class="fieldtype">
623 <a id="a6a5183df4c54c3e28dc8dc704f2487d5" name="a6a5183df4c54c3e28dc8dc704f2487d5"></a><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
624 <td class="fieldname">
626 <td class="fielddoc">
627 initial thread priority (default: osPriorityNormal) <p>Specifies the initial thread priority with a value from <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec" title="Priority values.">osPriority_t</a>.</p>
628 <p>Default: <span class="XML-Token">osPriorityNormal</span>. </p>
630 <tr><td class="fieldtype">
631 <a id="a697f2aad6119d655d212ea10245ae394" name="a697f2aad6119d655d212ea10245ae394"></a><a class="el" href="cmsis__os2_8h.html#ad5ef21485fe5f60263bc0b48006202cb">TZ_ModuleId_t</a></td>
632 <td class="fieldname">
634 <td class="fielddoc">
635 TrustZone module identifier. <p>TrustZone Thread Context Management Identifier to allocate context memory for threads. The RTOS kernel that runs in non-secure state calls the interface functions defined by the header file TZ_context.h. Can safely be set to zero for threads not using secure calls at all. See <a href="../../Core/html/group__context__trustzone__functions.html">TrustZone RTOS Context Management</a>.</p>
636 <p>Default: <span class="XML-Token">0</span> not thread context specified. </p>
638 <tr><td class="fieldtype">
639 <a id="a66f538babc389986738ec70104e0562b" name="a66f538babc389986738ec70104e0562b"></a>uint32_t</td>
640 <td class="fieldname">
642 <td class="fielddoc">
643 reserved (must be 0) <p>Reserved for future use. </p>
649 <h2 class="groupheader">Macro Definition Documentation</h2>
650 <a id="ga249499c519f3f8eef5673009ab6cfcbe" name="ga249499c519f3f8eef5673009ab6cfcbe"></a>
651 <h2 class="memtitle"><span class="permalink"><a href="#ga249499c519f3f8eef5673009ab6cfcbe">◆ </a></span>osThreadJoinable</h2>
653 <div class="memitem">
654 <div class="memproto">
655 <table class="memname">
657 <td class="memname">#define osThreadJoinable   0x00000001U</td>
660 </div><div class="memdoc">
661 <p>Bitmask for a thread that can be joined. Intended for use in <em>attr_bits</em> of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> type argument for <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function.</p>
662 <p>A thread in this state can be joined using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>
666 <a id="gaa9336c1073858d6b118e2e011636246f" name="gaa9336c1073858d6b118e2e011636246f"></a>
667 <h2 class="memtitle"><span class="permalink"><a href="#gaa9336c1073858d6b118e2e011636246f">◆ </a></span>osThreadDetached</h2>
669 <div class="memitem">
670 <div class="memproto">
671 <table class="memname">
673 <td class="memname">#define osThreadDetached   0x00000000U</td>
676 </div><div class="memdoc">
677 <p>Bitmask for a thread that cannot be joined. Intended for use in <em>attr_bits</em> of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> type argument for <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function.</p>
678 <p>A thread in this state cannot be joined using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>
682 <a id="ga4c028e5c3f4d86d237a1e09ceaf84792" name="ga4c028e5c3f4d86d237a1e09ceaf84792"></a>
683 <h2 class="memtitle"><span class="permalink"><a href="#ga4c028e5c3f4d86d237a1e09ceaf84792">◆ </a></span>osThreadUnprivileged</h2>
685 <div class="memitem">
686 <div class="memproto">
687 <table class="memname">
689 <td class="memname">#define osThreadUnprivileged   0x00000002U</td>
692 </div><div class="memdoc">
693 <p>Bitmask for a thread that runs in unprivileged mode. Intended for use in <em>attr_bits</em> of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> type argument for <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function.</p>
694 <p>In <b>unprivileged</b> processor mode, a thread:</p><ul>
695 <li>has limited access to the MSR and MRS instructions, and cannot use the CPS instruction.</li>
696 <li>cannot access the system timer, NVIC, or system control block.</li>
697 <li>might have restricted access to memory or peripherals.</li>
699 <dl class="section note"><dt>Note</dt><dd>Ignored on processors that only run in privileged mode.</dd></dl>
700 <p>Refer to the target processor User's Guide for details. </p>
704 <a id="ga7c2b7db42d23e4f56132e0ed739d02e5" name="ga7c2b7db42d23e4f56132e0ed739d02e5"></a>
705 <h2 class="memtitle"><span class="permalink"><a href="#ga7c2b7db42d23e4f56132e0ed739d02e5">◆ </a></span>osThreadPrivileged</h2>
707 <div class="memitem">
708 <div class="memproto">
709 <table class="memname">
711 <td class="memname">#define osThreadPrivileged   0x00000004U</td>
714 </div><div class="memdoc">
715 <p>Bitmask for a thread that runs in privileged mode. Intended for use in <em>attr_bits</em> of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> type argument for <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> function.</p>
716 <p>In <b>privileged</b> processor mode, the application software can use all the instructions and has access to all resources. </p>
720 <a id="gaefca370070d0b1616421bc3311acfecc" name="gaefca370070d0b1616421bc3311acfecc"></a>
721 <h2 class="memtitle"><span class="permalink"><a href="#gaefca370070d0b1616421bc3311acfecc">◆ </a></span>osThreadZone</h2>
723 <div class="memitem">
724 <div class="memproto">
725 <table class="memname">
727 <td class="memname">#define osThreadZone</td>
729 <td class="paramtype"> </td>
730 <td class="paramname">n</td><td>)</td>
734 </div><div class="memdoc">
735 <p>MPU protected zone.</p>
736 <dl class="params"><dt>Parameters</dt><dd>
737 <table class="params">
738 <tr><td class="paramname">n</td><td>MPU Protected Zone value.</td></tr>
742 <p>The preprocessor macro <b>osThreadZone</b> constructs attribute bitmask with MPU zone bits set to <em>n</em>.</p>
743 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="comment">/* ThreadB thread attributes */</span></div>
744 <div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread_B_attr = {</div>
745 <div class="line"> .<a class="code hl_variable" href="group__CMSIS__RTOS__ThreadMgmt.html#ab74e6bf80237ddc4109968cedc58c151">name</a> = <span class="stringliteral">"ThreadB"</span>, <span class="comment">// human readable thread name</span></div>
746 <div class="line"> .attr_bits = <a class="code hl_define" href="group__CMSIS__RTOS__ThreadMgmt.html#gaefca370070d0b1616421bc3311acfecc">osThreadZone</a>(3U) <span class="comment">// assign thread to MPU zone 3</span></div>
747 <div class="line">};</div>
748 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ab74e6bf80237ddc4109968cedc58c151"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ab74e6bf80237ddc4109968cedc58c151">osThreadAttr_t::name</a></div><div class="ttdeci">const char * name</div><div class="ttdoc">name of the thread</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:283</div></div>
749 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gaefca370070d0b1616421bc3311acfecc"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gaefca370070d0b1616421bc3311acfecc">osThreadZone</a></div><div class="ttdeci">#define osThreadZone(n)</div><div class="ttdoc">MPU zone value in attribute bit field format.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:214</div></div>
750 </div><!-- fragment -->
753 <h2 class="groupheader">Typedef Documentation</h2>
754 <a id="gadd51f99a6eb50b94eee75f27cae815eb" name="gadd51f99a6eb50b94eee75f27cae815eb"></a>
755 <h2 class="memtitle"><span class="permalink"><a href="#gadd51f99a6eb50b94eee75f27cae815eb">◆ </a></span>osThreadFunc_t</h2>
757 <div class="memitem">
758 <div class="memproto">
759 <table class="memname">
761 <td class="memname">void(* osThreadFunc_t)(void *argument)</td>
764 </div><div class="memdoc">
765 <p>Entry function for threads. Setting up a new thread (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>) will start execution with a call into this entry function. The optional argument can be used to hand over arbitrary user data to the thread, i.e. to identify the thread or for runtime parameters.</p>
766 <dl class="params"><dt>Parameters</dt><dd>
767 <table class="params">
768 <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>Arbitrary user data set on <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>. </td></tr>
775 <a id="gaa6c32fe2a3e0a2e01f212d55b02e51c7" name="gaa6c32fe2a3e0a2e01f212d55b02e51c7"></a>
776 <h2 class="memtitle"><span class="permalink"><a href="#gaa6c32fe2a3e0a2e01f212d55b02e51c7">◆ </a></span>osThreadId_t</h2>
778 <div class="memitem">
779 <div class="memproto">
780 <table class="memname">
782 <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td>
785 </div><div class="memdoc">
786 <p>Thread ID identifies the thread.</p>
787 <p>Returned by:</p><ul>
788 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a></li>
789 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a></li>
790 <li><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5606604d56e21ece1a654664be877439">osThreadEnumerate</a></li>
791 <li><a class="el" href="group__CMSIS__RTOS__MutexMgmt.html#ga7f9a7666df0978738cd570cb700b83fb">osMutexGetOwner</a> </li>
796 <h2 class="groupheader">Enumeration Type Documentation</h2>
797 <a id="gad3dc89e942e38d9f3af858a0269a820d" name="gad3dc89e942e38d9f3af858a0269a820d"></a>
798 <h2 class="memtitle"><span class="permalink"><a href="#gad3dc89e942e38d9f3af858a0269a820d">◆ </a></span>osThreadState_t</h2>
800 <div class="memitem">
801 <div class="memproto">
802 <table class="memname">
804 <td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a></td>
807 </div><div class="memdoc">
808 <p>State of a thread as retrieved by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a>. In case <b>osThreadGetState</b> fails or if it is called from an ISR, it will return <code>osThreadError</code>, otherwise it returns the thread state. </p>
809 <table class="fieldtable">
810 <tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820dae9d77830b6866e287417b6e1d983e971" name="ggad3dc89e942e38d9f3af858a0269a820dae9d77830b6866e287417b6e1d983e971"></a>osThreadInactive </td><td class="fielddoc"><p>Inactive. </p>
811 <p>The thread is created but not actively used, or has been terminated (returned for static control block allocation, when memory pools are used <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a> is returned as the control block is no longer valid) </p>
813 <tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820da59e286915944fe0e4d1ffdb1f2946f14" name="ggad3dc89e942e38d9f3af858a0269a820da59e286915944fe0e4d1ffdb1f2946f14"></a>osThreadReady </td><td class="fielddoc"><p>Ready. </p>
814 <p>The thread is ready for execution but not currently running. </p>
816 <tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820dac4fe336e0790188fcf7d667372eca19d" name="ggad3dc89e942e38d9f3af858a0269a820dac4fe336e0790188fcf7d667372eca19d"></a>osThreadRunning </td><td class="fielddoc"><p>Running. </p>
817 <p>The thread is currently running. </p>
819 <tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968" name="ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968"></a>osThreadBlocked </td><td class="fielddoc"><p>Blocked. </p>
820 <p>The thread is currently blocked (delayed, waiting for an event or suspended). </p>
822 <tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c" name="ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c"></a>osThreadTerminated </td><td class="fielddoc"><p>Terminated. </p>
823 <p>The thread is terminated and all its resources are not yet freed (applies to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#joinable_threads">joinable threads).</a></p>
825 <tr><td class="fieldname"><a id="ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e" name="ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e"></a>osThreadError </td><td class="fielddoc"><p>Error. </p>
826 <p>The thread does not exist (has raised an error condition) and cannot be scheduled. </p>
828 <tr><td class="fieldname"><a id="gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c" name="gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c"></a>osThreadReserved </td><td class="fielddoc"><p>Prevents enum down-size compiler optimization. </p>
834 <a id="gad4e3e0971b41f2d17584a8c6837342ec" name="gad4e3e0971b41f2d17584a8c6837342ec"></a>
835 <h2 class="memtitle"><span class="permalink"><a href="#gad4e3e0971b41f2d17584a8c6837342ec">◆ </a></span>osPriority_t</h2>
837 <div class="memitem">
838 <div class="memproto">
839 <table class="memname">
841 <td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
844 </div><div class="memdoc">
845 <p>The <b>osPriority_t</b> value specifies the priority for a thread. The default thread priority should be <em>osPriorityNormal</em>. If an active thread becomes ready that has a higher priority than the currently running thread then a thread switch occurs immediately. The system continues executing the thread with the higher priority.</p>
846 <p>To prevent from a priority inversion, a CMSIS-RTOS compliant OS may optionally implement a <b>priority inheritance</b> method. A priority inversion occurs when a high priority thread is waiting for a resource or event that is controlled by a thread with a lower priority. Thus causing the high priority thread potentially being blocked forever by another thread with lower priority. To come over this issue the low priority thread controlling the resource should be treated as having the higher priority until it releases the resource.</p>
847 <dl class="section note"><dt>Note</dt><dd>Priority inheritance only applies to mutexes. </dd></dl>
848 <table class="fieldtable">
849 <tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3" name="gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3"></a>osPriorityNone </td><td class="fielddoc"><p>No priority (not initialized). </p>
851 <tr><td class="fieldname"><a id="ggad4e3e0971b41f2d17584a8c6837342ecacd5864eac01a6916a7c866bb51a6aac1" name="ggad4e3e0971b41f2d17584a8c6837342ecacd5864eac01a6916a7c866bb51a6aac1"></a>osPriorityIdle </td><td class="fielddoc"><p>Reserved for Idle thread. </p>
852 <p>This lowest priority should not be used for any other thread. </p>
854 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4" name="gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4"></a>osPriorityLow </td><td class="fielddoc"><p>Priority: low. </p>
856 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe" name="gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe"></a>osPriorityLow1 </td><td class="fielddoc"><p>Priority: low + 1. </p>
858 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507" name="gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507"></a>osPriorityLow2 </td><td class="fielddoc"><p>Priority: low + 2. </p>
860 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50" name="gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50"></a>osPriorityLow3 </td><td class="fielddoc"><p>Priority: low + 3. </p>
862 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81" name="gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81"></a>osPriorityLow4 </td><td class="fielddoc"><p>Priority: low + 4. </p>
864 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353" name="gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353"></a>osPriorityLow5 </td><td class="fielddoc"><p>Priority: low + 5. </p>
866 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393" name="gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393"></a>osPriorityLow6 </td><td class="fielddoc"><p>Priority: low + 6. </p>
868 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a" name="gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a"></a>osPriorityLow7 </td><td class="fielddoc"><p>Priority: low + 7. </p>
870 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6" name="gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6"></a>osPriorityBelowNormal </td><td class="fielddoc"><p>Priority: below normal. </p>
872 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5" name="gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5"></a>osPriorityBelowNormal1 </td><td class="fielddoc"><p>Priority: below normal + 1. </p>
874 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3" name="gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3"></a>osPriorityBelowNormal2 </td><td class="fielddoc"><p>Priority: below normal + 2. </p>
876 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf" name="gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf"></a>osPriorityBelowNormal3 </td><td class="fielddoc"><p>Priority: below normal + 3. </p>
878 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24" name="gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24"></a>osPriorityBelowNormal4 </td><td class="fielddoc"><p>Priority: below normal + 4. </p>
880 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e" name="gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e"></a>osPriorityBelowNormal5 </td><td class="fielddoc"><p>Priority: below normal + 5. </p>
882 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05" name="gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05"></a>osPriorityBelowNormal6 </td><td class="fielddoc"><p>Priority: below normal + 6. </p>
884 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b" name="gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b"></a>osPriorityBelowNormal7 </td><td class="fielddoc"><p>Priority: below normal + 7. </p>
886 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1" name="gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1"></a>osPriorityNormal </td><td class="fielddoc"><p>Priority: normal. </p>
888 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c" name="gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c"></a>osPriorityNormal1 </td><td class="fielddoc"><p>Priority: normal + 1. </p>
890 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205" name="gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205"></a>osPriorityNormal2 </td><td class="fielddoc"><p>Priority: normal + 2. </p>
892 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91" name="gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91"></a>osPriorityNormal3 </td><td class="fielddoc"><p>Priority: normal + 3. </p>
894 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d" name="gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d"></a>osPriorityNormal4 </td><td class="fielddoc"><p>Priority: normal + 4. </p>
896 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab" name="gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab"></a>osPriorityNormal5 </td><td class="fielddoc"><p>Priority: normal + 5. </p>
898 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204" name="gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204"></a>osPriorityNormal6 </td><td class="fielddoc"><p>Priority: normal + 6. </p>
900 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b" name="gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b"></a>osPriorityNormal7 </td><td class="fielddoc"><p>Priority: normal + 7. </p>
902 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b" name="gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b"></a>osPriorityAboveNormal </td><td class="fielddoc"><p>Priority: above normal. </p>
904 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998" name="gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998"></a>osPriorityAboveNormal1 </td><td class="fielddoc"><p>Priority: above normal + 1. </p>
906 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562" name="gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562"></a>osPriorityAboveNormal2 </td><td class="fielddoc"><p>Priority: above normal + 2. </p>
908 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013" name="gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013"></a>osPriorityAboveNormal3 </td><td class="fielddoc"><p>Priority: above normal + 3. </p>
910 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec" name="gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec"></a>osPriorityAboveNormal4 </td><td class="fielddoc"><p>Priority: above normal + 4. </p>
912 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c" name="gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c"></a>osPriorityAboveNormal5 </td><td class="fielddoc"><p>Priority: above normal + 5. </p>
914 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207" name="gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207"></a>osPriorityAboveNormal6 </td><td class="fielddoc"><p>Priority: above normal + 6. </p>
916 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d" name="gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d"></a>osPriorityAboveNormal7 </td><td class="fielddoc"><p>Priority: above normal + 7. </p>
918 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2" name="gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2"></a>osPriorityHigh </td><td class="fielddoc"><p>Priority: high. </p>
920 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb" name="gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb"></a>osPriorityHigh1 </td><td class="fielddoc"><p>Priority: high + 1. </p>
922 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03" name="gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03"></a>osPriorityHigh2 </td><td class="fielddoc"><p>Priority: high + 2. </p>
924 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759" name="gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759"></a>osPriorityHigh3 </td><td class="fielddoc"><p>Priority: high + 3. </p>
926 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb" name="gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb"></a>osPriorityHigh4 </td><td class="fielddoc"><p>Priority: high + 4. </p>
928 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9" name="gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9"></a>osPriorityHigh5 </td><td class="fielddoc"><p>Priority: high + 5. </p>
930 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc" name="gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc"></a>osPriorityHigh6 </td><td class="fielddoc"><p>Priority: high + 6. </p>
932 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652" name="gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652"></a>osPriorityHigh7 </td><td class="fielddoc"><p>Priority: high + 7. </p>
934 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af" name="gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af"></a>osPriorityRealtime </td><td class="fielddoc"><p>Priority: realtime. </p>
936 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b" name="gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b"></a>osPriorityRealtime1 </td><td class="fielddoc"><p>Priority: realtime + 1. </p>
938 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff" name="gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff"></a>osPriorityRealtime2 </td><td class="fielddoc"><p>Priority: realtime + 2. </p>
940 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa" name="gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa"></a>osPriorityRealtime3 </td><td class="fielddoc"><p>Priority: realtime + 3. </p>
942 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70" name="gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70"></a>osPriorityRealtime4 </td><td class="fielddoc"><p>Priority: realtime + 4. </p>
944 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df" name="gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df"></a>osPriorityRealtime5 </td><td class="fielddoc"><p>Priority: realtime + 5. </p>
946 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194" name="gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194"></a>osPriorityRealtime6 </td><td class="fielddoc"><p>Priority: realtime + 6. </p>
948 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b" name="gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b"></a>osPriorityRealtime7 </td><td class="fielddoc"><p>Priority: realtime + 7. </p>
950 <tr><td class="fieldname"><a id="ggad4e3e0971b41f2d17584a8c6837342eca4b4fa46c3ebaf4259662a0a0a3173b7f" name="ggad4e3e0971b41f2d17584a8c6837342eca4b4fa46c3ebaf4259662a0a0a3173b7f"></a>osPriorityISR </td><td class="fielddoc"><p>Reserved for ISR deferred thread. </p>
951 <p>This highest priority might be used by the RTOS implementation but must not be used for any user thread. </p>
953 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4" name="gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4"></a>osPriorityError </td><td class="fielddoc"><p>System cannot determine priority or illegal priority. </p>
955 <tr><td class="fieldname"><a id="gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b" name="gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b"></a>osPriorityReserved </td><td class="fielddoc"><p>Prevents enum down-size compiler optimization. </p>
961 <h2 class="groupheader">Function Documentation</h2>
962 <a id="ga48d68b8666d99d28fa646ee1d2182b8f" name="ga48d68b8666d99d28fa646ee1d2182b8f"></a>
963 <h2 class="memtitle"><span class="permalink"><a href="#ga48d68b8666d99d28fa646ee1d2182b8f">◆ </a></span>osThreadNew()</h2>
965 <div class="memitem">
966 <div class="memproto">
967 <table class="memname">
969 <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadNew </td>
971 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a> </td>
972 <td class="paramname"><em>func</em>, </td>
975 <td class="paramkey"></td>
977 <td class="paramtype">void * </td>
978 <td class="paramname"><em>argument</em>, </td>
981 <td class="paramkey"></td>
983 <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> * </td>
984 <td class="paramname"><em>attr</em> </td>
992 </div><div class="memdoc">
993 <dl class="params"><dt>Parameters</dt><dd>
994 <table class="params">
995 <tr><td class="paramdir">[in]</td><td class="paramname">func</td><td>thread function. </td></tr>
996 <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>pointer that is passed to the thread function as start argument. </td></tr>
997 <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>thread attributes; NULL: default values. </td></tr>
1001 <dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
1002 <p>The function <b>osThreadNew</b> starts a thread function by adding it to the list of active threads and sets it to state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a>. Arguments for the thread function are passed using the parameter pointer <em>*argument</em>. When the priority of the created thread function is higher than the current <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread, the created thread function starts instantly and becomes the new <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a> thread. Thread attributes are defined with the parameter pointer <em>attr</em>. Attributes include settings for thread priority, stack size, or memory allocation.</p>
1003 <p>The function 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>
1004 <p>The function <b>osThreadNew</b> returns the pointer to the thread object identifier or <span class="XML-Token">NULL</span> in case of an error.</p>
1005 <dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
1006 <p><b>Code</b> <b>Example</b> </p>
1007 <p>Refer to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#thread_examples">Thread Examples</a> section. </p>
1011 <a id="gac3230f3a55a297514b013ebf38f27e0a" name="gac3230f3a55a297514b013ebf38f27e0a"></a>
1012 <h2 class="memtitle"><span class="permalink"><a href="#gac3230f3a55a297514b013ebf38f27e0a">◆ </a></span>osThreadGetName()</h2>
1014 <div class="memitem">
1015 <div class="memproto">
1016 <table class="memname">
1018 <td class="memname">const char * osThreadGetName </td>
1020 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1021 <td class="paramname"><em>thread_id</em></td><td>)</td>
1025 </div><div class="memdoc">
1026 <dl class="params"><dt>Parameters</dt><dd>
1027 <table class="params">
1028 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1032 <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
1033 <p>The function <b>osThreadGetName</b> returns the pointer to the name string of the thread identified by parameter <em>thread_id</em> or <span class="XML-Token">NULL</span> in case of an error.</p>
1034 <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>
1035 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> ThreadGetName_example (<span class="keywordtype">void</span>) {</div>
1036 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();</div>
1037 <div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span>* name = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a>(thread_id);</div>
1038 <div class="line"> <span class="keywordflow">if</span> (name == NULL) {</div>
1039 <div class="line"> <span class="comment">// Failed to get the thread name; not in a thread</span></div>
1040 <div class="line"> }</div>
1041 <div class="line">}</div>
1042 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga8df03548e89fbc56402a5cd584a505da"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a></div><div class="ttdeci">osThreadId_t osThreadGetId(void)</div><div class="ttdoc">Return the thread ID of the current running thread.</div></div>
1043 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gac3230f3a55a297514b013ebf38f27e0a"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a></div><div class="ttdeci">const char * osThreadGetName(osThreadId_t thread_id)</div><div class="ttdoc">Get name of a thread.</div></div>
1044 </div><!-- fragment -->
1047 <a id="ga1bfbef7da94ed4147d231e8d6eeb5f3e" name="ga1bfbef7da94ed4147d231e8d6eeb5f3e"></a>
1048 <h2 class="memtitle"><span class="permalink"><a href="#ga1bfbef7da94ed4147d231e8d6eeb5f3e">◆ </a></span>osThreadGetClass()</h2>
1050 <div class="memitem">
1051 <div class="memproto">
1052 <table class="memname">
1054 <td class="memname">uint32_t osThreadGetClass </td>
1056 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1057 <td class="paramname"><em>thread_id</em></td><td>)</td>
1061 </div><div class="memdoc">
1062 <dl class="params"><dt>Parameters</dt><dd>
1063 <table class="params">
1064 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1068 <dl class="section return"><dt>Returns</dt><dd>safety class of the specified thread.</dd></dl>
1069 <p>The function <b>osThreadGetClass</b> returns safety class assigned to the thread identified by parameter <em>thread_id</em>. In case of an error, it returns <a class="el" href="cmsis__os2_8h.html#a6f3bd4b67fb89bd085266fe65ee45b06">osErrorId</a>. </p>
1073 <a id="ga4101737fa4fd303d4b41fdca6b994f8e" name="ga4101737fa4fd303d4b41fdca6b994f8e"></a>
1074 <h2 class="memtitle"><span class="permalink"><a href="#ga4101737fa4fd303d4b41fdca6b994f8e">◆ </a></span>osThreadGetZone()</h2>
1076 <div class="memitem">
1077 <div class="memproto">
1078 <table class="memname">
1080 <td class="memname">uint32_t osThreadGetZone </td>
1082 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1083 <td class="paramname"><em>thread_id</em></td><td>)</td>
1087 </div><div class="memdoc">
1088 <dl class="params"><dt>Parameters</dt><dd>
1089 <table class="params">
1090 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1094 <dl class="section return"><dt>Returns</dt><dd>MPU protected zone of the specified thread.</dd></dl>
1095 <p>The function <b>osThreadGetZone</b> returns the MPU Protected Zone value assigned to the thread identified by parameter <em>thread_id</em>. In case of an error, it returns <a class="el" href="cmsis__os2_8h.html#a6f3bd4b67fb89bd085266fe65ee45b06">osErrorId</a>. </p>
1099 <a id="ga8df03548e89fbc56402a5cd584a505da" name="ga8df03548e89fbc56402a5cd584a505da"></a>
1100 <h2 class="memtitle"><span class="permalink"><a href="#ga8df03548e89fbc56402a5cd584a505da">◆ </a></span>osThreadGetId()</h2>
1102 <div class="memitem">
1103 <div class="memproto">
1104 <table class="memname">
1106 <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadGetId </td>
1108 <td class="paramtype">void </td>
1109 <td class="paramname"></td><td>)</td>
1113 </div><div class="memdoc">
1114 <dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
1115 <p>The function <b>osThreadGetId</b> returns the thread object ID of the currently running thread or NULL in case of an error.</p>
1116 <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>
1117 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> ThreadGetId_example (<span class="keywordtype">void</span>) {</div>
1118 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
1119 <div class="line"> </div>
1120 <div class="line"> <span class="keywordtype">id</span> = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>();</div>
1121 <div class="line"> <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == NULL) {</div>
1122 <div class="line"> <span class="comment">// Failed to get the id</span></div>
1123 <div class="line"> }</div>
1124 <div class="line">}</div>
1125 </div><!-- fragment -->
1128 <a id="gacc0a98b42f0a5928e12dc91dc76866b9" name="gacc0a98b42f0a5928e12dc91dc76866b9"></a>
1129 <h2 class="memtitle"><span class="permalink"><a href="#gacc0a98b42f0a5928e12dc91dc76866b9">◆ </a></span>osThreadGetState()</h2>
1131 <div class="memitem">
1132 <div class="memproto">
1133 <table class="memname">
1135 <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> osThreadGetState </td>
1137 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1138 <td class="paramname"><em>thread_id</em></td><td>)</td>
1142 </div><div class="memdoc">
1143 <dl class="params"><dt>Parameters</dt><dd>
1144 <table class="params">
1145 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1149 <dl class="section return"><dt>Returns</dt><dd>current thread state of the specified thread.</dd></dl>
1150 <p>The function <b>osThreadGetState</b> returns the state of the thread identified by parameter <em>thread_id</em>. In case it fails or if it is called from an ISR, it will return <code>osThreadError</code>, otherwise it returns the thread state (refer to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> for the list of thread states).</p>
1151 <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>
1155 <a id="ga861a420fb2d643115b06622903fb3bfb" name="ga861a420fb2d643115b06622903fb3bfb"></a>
1156 <h2 class="memtitle"><span class="permalink"><a href="#ga861a420fb2d643115b06622903fb3bfb">◆ </a></span>osThreadSetPriority()</h2>
1158 <div class="memitem">
1159 <div class="memproto">
1160 <table class="memname">
1162 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSetPriority </td>
1164 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1165 <td class="paramname"><em>thread_id</em>, </td>
1168 <td class="paramkey"></td>
1170 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> </td>
1171 <td class="paramname"><em>priority</em> </td>
1179 </div><div class="memdoc">
1180 <dl class="params"><dt>Parameters</dt><dd>
1181 <table class="params">
1182 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1183 <tr><td class="paramdir">[in]</td><td class="paramname">priority</td><td>new priority value for the thread function. </td></tr>
1187 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1188 <p>The function <b>osThreadSetPriority</b> changes the priority of an active thread specified by the parameter <em>thread_id</em> to the priority specified by the parameter <em>priority</em>.</p>
1189 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1190 <li><em>osOK:</em> the priority of the specified thread has been changed successfully.</li>
1191 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid or <em>priority</em> is incorrect.</li>
1192 <li><em>osErrorResource:</em> the thread is in an invalid state.</li>
1193 <li><em>osErrorISR:</em> the function <b>osThreadSetPriority</b> cannot be called from interrupt service routines.</li>
1194 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1196 <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>
1197 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1198 <div class="line"> </div>
1199 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) { <span class="comment">// Thread function</span></div>
1200 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
1201 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// status of the executed function</span></div>
1202 <div class="line"> </div>
1203 <div class="line"> :</div>
1204 <div class="line"> <span class="keywordtype">id</span> = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>(); <span class="comment">// Obtain ID of current running thread</span></div>
1205 <div class="line"> </div>
1206 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a>(<span class="keywordtype">id</span>, <a class="code hl_enumvalue" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a>); <span class="comment">// Set thread priority</span></div>
1207 <div class="line"> <span class="keywordflow">if</span> (status == <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
1208 <div class="line"> <span class="comment">// Thread priority changed to BelowNormal</span></div>
1209 <div class="line"> }</div>
1210 <div class="line"> <span class="keywordflow">else</span> {</div>
1211 <div class="line"> <span class="comment">// Failed to set the priority</span></div>
1212 <div class="line"> }</div>
1213 <div class="line"> :</div>
1214 <div class="line">}</div>
1215 <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>
1216 <div class="ttc" id="acmsis__os2_8h_html_gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6"><div class="ttname"><a href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a></div><div class="ttdeci">@ osPriorityBelowNormal</div><div class="ttdoc">Priority: below normal.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:131</div></div>
1217 <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>
1218 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga861a420fb2d643115b06622903fb3bfb"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a></div><div class="ttdeci">osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)</div><div class="ttdoc">Change priority of a thread.</div></div>
1219 </div><!-- fragment -->
1222 <a id="ga0aeaf349604f456e68e78f9d3b42e44b" name="ga0aeaf349604f456e68e78f9d3b42e44b"></a>
1223 <h2 class="memtitle"><span class="permalink"><a href="#ga0aeaf349604f456e68e78f9d3b42e44b">◆ </a></span>osThreadGetPriority()</h2>
1225 <div class="memitem">
1226 <div class="memproto">
1227 <table class="memname">
1229 <td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> osThreadGetPriority </td>
1231 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1232 <td class="paramname"><em>thread_id</em></td><td>)</td>
1236 </div><div class="memdoc">
1237 <dl class="params"><dt>Parameters</dt><dd>
1238 <table class="params">
1239 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1243 <dl class="section return"><dt>Returns</dt><dd>current priority value of the specified thread.</dd></dl>
1244 <p>The function <b>osThreadGetPriority</b> returns the priority of an active thread specified by the parameter <em>thread_id</em>.</p>
1245 <p>Possible <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> return values:</p><ul>
1246 <li><em>priority:</em> the priority of the specified thread.</li>
1247 <li><em>osPriorityError:</em> priority cannot be determined or is illegal. It is also returned when the function is called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</li>
1249 <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>
1250 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1251 <div class="line"> </div>
1252 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) { <span class="comment">// Thread function</span></div>
1253 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
1254 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> priority; <span class="comment">// thread priority</span></div>
1255 <div class="line"> </div>
1256 <div class="line"> <span class="keywordtype">id</span> = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>(); <span class="comment">// Obtain ID of current running thread</span></div>
1257 <div class="line"> priority = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a>(<span class="keywordtype">id</span>); <span class="comment">// Obtain the thread priority</span></div>
1258 <div class="line">}</div>
1259 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga0aeaf349604f456e68e78f9d3b42e44b"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a></div><div class="ttdeci">osPriority_t osThreadGetPriority(osThreadId_t thread_id)</div><div class="ttdoc">Get current priority of a thread.</div></div>
1260 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gad4e3e0971b41f2d17584a8c6837342ec"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></div><div class="ttdeci">osPriority_t</div><div class="ttdoc">Priority values.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:120</div></div>
1261 </div><!-- fragment -->
1264 <a id="gad01c7ec26535b1de6b018bb9466720e2" name="gad01c7ec26535b1de6b018bb9466720e2"></a>
1265 <h2 class="memtitle"><span class="permalink"><a href="#gad01c7ec26535b1de6b018bb9466720e2">◆ </a></span>osThreadYield()</h2>
1267 <div class="memitem">
1268 <div class="memproto">
1269 <table class="memname">
1271 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadYield </td>
1273 <td class="paramtype">void </td>
1274 <td class="paramname"></td><td>)</td>
1278 </div><div class="memdoc">
1279 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1280 <p>The function <b>osThreadYield</b> passes control to the next thread with the same priority that is in the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. If there is no other thread with the same priority in state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a>, then the current thread continues execution and no thread switch occurs. <b>osThreadYield</b> does not set the thread to state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a>. Thus no thread with a lower priority will be scheduled even if threads in state <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> are available.</p>
1281 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1282 <li><em>osOK:</em> control has been passed to the next thread successfully.</li>
1283 <li><em>osError:</em> an unspecified error has occurred.</li>
1284 <li><em>osErrorISR:</em> the function <b>osThreadYield</b> cannot be called from interrupt service routines.</li>
1286 <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>
1288 This function <b>has no impact</b> when called when the kernel is locked, see <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>.</dd></dl>
1289 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1290 <div class="line"> </div>
1291 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) { <span class="comment">// Thread function</span></div>
1292 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// status of the executed function</span></div>
1293 <div class="line"> :</div>
1294 <div class="line"> <span class="keywordflow">while</span> (1) {</div>
1295 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>();</div>
1296 <div class="line"> <span class="keywordflow">if</span> (status != <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
1297 <div class="line"> <span class="comment">// an error occurred</span></div>
1298 <div class="line"> }</div>
1299 <div class="line"> }</div>
1300 <div class="line">}</div>
1301 <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>
1302 </div><!-- fragment -->
1305 <a id="gaa9de419d0152bf77e9bbcd1f369fb990" name="gaa9de419d0152bf77e9bbcd1f369fb990"></a>
1306 <h2 class="memtitle"><span class="permalink"><a href="#gaa9de419d0152bf77e9bbcd1f369fb990">◆ </a></span>osThreadSuspend()</h2>
1308 <div class="memitem">
1309 <div class="memproto">
1310 <table class="memname">
1312 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSuspend </td>
1314 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1315 <td class="paramname"><em>thread_id</em></td><td>)</td>
1319 </div><div class="memdoc">
1320 <dl class="params"><dt>Parameters</dt><dd>
1321 <table class="params">
1322 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1326 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1327 <p>The function <b>osThreadSuspend</b> suspends the execution of the thread identified by parameter <em>thread_id</em>. The thread is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820daf0e992e354fba8695957c530226a4968">osThreadBlocked</a>). Suspending the running thread will cause a context switch to another thread in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state immediately. The suspended thread is not executed until explicitly resumed with the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a>.</p>
1328 <p>Threads that are already <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> are removed from any wait list and become ready when they are resumed. Thus it is not recommended to suspend an already blocked thread.</p>
1329 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1330 <li><em>osOK:</em> the thread has been suspended successfully.</li>
1331 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
1332 <li><em>osErrorResource:</em> the thread is in an invalid state.</li>
1333 <li><em>osErrorISR:</em> the function <b>osThreadSuspend</b> cannot be called from interrupt service routines.</li>
1334 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1336 <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>
1338 This function <b>must not</b> be called to suspend the running thread when the kernel is locked, i.e. <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>. </dd></dl>
1342 <a id="ga3dbad90eff394b02de76a452c84c5d80" name="ga3dbad90eff394b02de76a452c84c5d80"></a>
1343 <h2 class="memtitle"><span class="permalink"><a href="#ga3dbad90eff394b02de76a452c84c5d80">◆ </a></span>osThreadResume()</h2>
1345 <div class="memitem">
1346 <div class="memproto">
1347 <table class="memname">
1349 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadResume </td>
1351 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1352 <td class="paramname"><em>thread_id</em></td><td>)</td>
1356 </div><div class="memdoc">
1357 <dl class="params"><dt>Parameters</dt><dd>
1358 <table class="params">
1359 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1363 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1364 <p>The function <b>osThreadResume</b> puts the thread identified by parameter <em>thread_id</em> (which has to be in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state) back to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state. If the resumed thread has a higher priority than the running thread a context switch occurs immediately.</p>
1365 <p>The thread becomes ready regardless of the reason why the thread was blocked. Thus it is not recommended to resume a thread not suspended by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a>.</p>
1366 <p>Functions that will put a thread into <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state are: <a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> and <a class="el" href="group__CMSIS__RTOS__ThreadFlagsMgmt.html#gac11542ad6300b600f872fc96e340ec2b">osThreadFlagsWait</a>, <a class="el" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> and <a class="el" href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a>, <a class="el" href="group__CMSIS__RTOS__MutexMgmt.html#gabc54686ea0fc281823b1763422d2a924">osMutexAcquire</a> and <a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga7e94c8b242a0c81f2cc79ec22895c87b">osSemaphoreAcquire</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#gad90d4959466a7a65105061da8256ab9e">osMessageQueueGet</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>, <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a>.</p>
1367 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1368 <li><em>osOK:</em> the thread has been resumed successfully.</li>
1369 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
1370 <li><em>osErrorResource:</em> the thread is in an invalid state.</li>
1371 <li><em>osErrorISR:</em> the function <b>osThreadResume</b> cannot be called from interrupt service routines.</li>
1372 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1374 <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>
1376 This function <b>may be</b> called when kernel is locked (<a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga948609ee930d9b38336b9e1c2a4dfe12">osKernelLock</a>). Under this circumstances a potential context switch is delayed until the kernel gets unlocked, i.e. <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gaf401728b4657456198c33fe75f8d6720">osKernelUnlock</a> or <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae7d0a71b9586cbbb49fcbdf6a04f0289">osKernelRestoreLock</a>. </dd></dl>
1380 <a id="gaaad14cd9547341ea8109dc4e8540f1dc" name="gaaad14cd9547341ea8109dc4e8540f1dc"></a>
1381 <h2 class="memtitle"><span class="permalink"><a href="#gaaad14cd9547341ea8109dc4e8540f1dc">◆ </a></span>osThreadDetach()</h2>
1383 <div class="memitem">
1384 <div class="memproto">
1385 <table class="memname">
1387 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadDetach </td>
1389 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1390 <td class="paramname"><em>thread_id</em></td><td>)</td>
1394 </div><div class="memdoc">
1395 <dl class="params"><dt>Parameters</dt><dd>
1396 <table class="params">
1397 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1401 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1402 <p>The function <b>osThreadDetach</b> changes the attribute of a thread (specified by <em>thread_id</em>) to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>. Detached threads are not joinable with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. When a detached thread is terminated, all resources are returned to the system. The behavior of <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaaad14cd9547341ea8109dc4e8540f1dc">osThreadDetach</a> on an already detached thread is undefined.</p>
1403 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1404 <li><em>osOK:</em> the attribute of the specified thread has been changed to detached successfully.</li>
1405 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
1406 <li><em>osErrorResource:</em> the thread is in an invalid state.</li>
1407 <li><em>osErrorISR:</em> the function <b>osThreadDetach</b> cannot be called from interrupt service routines.</li>
1408 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1410 <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>
1414 <a id="ga3fca90fb0679afeb968aa8c3d5874487" name="ga3fca90fb0679afeb968aa8c3d5874487"></a>
1415 <h2 class="memtitle"><span class="permalink"><a href="#ga3fca90fb0679afeb968aa8c3d5874487">◆ </a></span>osThreadJoin()</h2>
1417 <div class="memitem">
1418 <div class="memproto">
1419 <table class="memname">
1421 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadJoin </td>
1423 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1424 <td class="paramname"><em>thread_id</em></td><td>)</td>
1428 </div><div class="memdoc">
1429 <dl class="params"><dt>Parameters</dt><dd>
1430 <table class="params">
1431 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1435 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1436 <p>The function <b>osThreadJoin</b> waits for the thread specified by <em>thread_id</em> to terminate. If that thread has already terminated, then <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> returns immediately. The thread must be joinable. By default threads are created with the attribute <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>.</p>
1437 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1438 <li><em>osOK:</em> if the thread has already been terminated and joined or once the thread has been terminated and the join operations succeeds.</li>
1439 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
1440 <li><em>osErrorResource:</em> the thread is in an invalid state (ex: not joinable).</li>
1441 <li><em>osErrorISR:</em> the function <b>osThreadJoin</b> cannot be called from interrupt service routines.</li>
1442 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1444 <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>. <br />
1447 Only one thread shall call <b>osThreadJoin</b> to join the target thread. If multiple threads try to join simultaneously with the same thread, the results are undefined. </dd></dl>
1451 <a id="gaddaa452dd7610e4096647a566d3556fc" name="gaddaa452dd7610e4096647a566d3556fc"></a>
1452 <h2 class="memtitle"><span class="permalink"><a href="#gaddaa452dd7610e4096647a566d3556fc">◆ </a></span>osThreadExit()</h2>
1454 <div class="memitem">
1455 <div class="memproto">
1456 <table class="memname">
1458 <td class="memname"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void osThreadExit </td>
1460 <td class="paramtype">void </td>
1461 <td class="paramname"></td><td>)</td>
1465 </div><div class="memdoc">
1466 <p>The function <b>osThreadExit</b> terminates the calling thread. This allows the thread to be synchronized with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>.</p>
1467 <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>
1468 <p><b>Code</b> <b>Example</b> </p><div class="fragment"><div class="line"><a class="code hl_define" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) {</div>
1469 <div class="line"> <span class="comment">// do something</span></div>
1470 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000U);</div>
1471 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
1472 <div class="line">}</div>
1473 </div><!-- fragment -->
1476 <a id="ga2f8ba6dba6e9c065a6e236ffd410d74a" name="ga2f8ba6dba6e9c065a6e236ffd410d74a"></a>
1477 <h2 class="memtitle"><span class="permalink"><a href="#ga2f8ba6dba6e9c065a6e236ffd410d74a">◆ </a></span>osThreadTerminate()</h2>
1479 <div class="memitem">
1480 <div class="memproto">
1481 <table class="memname">
1483 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadTerminate </td>
1485 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1486 <td class="paramname"><em>thread_id</em></td><td>)</td>
1490 </div><div class="memdoc">
1491 <dl class="params"><dt>Parameters</dt><dd>
1492 <table class="params">
1493 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1497 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1498 <p>The function <b>osThreadTerminate</b> removes the thread specified by parameter <em>thread_id</em> from the list of active threads. If the thread is currently <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">RUNNING</a>, the thread terminates and the execution continues with the next <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread. If no such thread exists, the function will not terminate the running thread, but return <em>osErrorResource</em>.</p>
1499 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1500 <li><em>osOK:</em> the specified thread has been removed from the active thread list successfully.</li>
1501 <li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
1502 <li><em>osErrorResource:</em> the thread is in an invalid state or no other <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists.</li>
1503 <li><em>osErrorISR:</em> the function <b>osThreadTerminate</b> cannot be called from interrupt service routines.</li>
1504 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified thread.</li>
1506 <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>
1508 Avoid calling the function with a <em>thread_id</em> that does not exist or has been terminated already. </dd>
1510 <b>osThreadTerminate</b> destroys non-joinable threads and removes their thread_id from the system. Subsequent access to the thread_id (for example <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a>) will return an <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a>. Joinable threads will not be destroyed and return the status <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c">osThreadTerminated</a> until they are joined with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>.</dd></dl>
1511 <p><b>Code Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1512 <div class="line"> </div>
1513 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> *arg); <span class="comment">// function prototype for Thread_1</span></div>
1514 <div class="line"> </div>
1515 <div class="line"><span class="keywordtype">void</span> ThreadTerminate_example (<span class="keywordtype">void</span>) {</div>
1516 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
1517 <div class="line"> <a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;</div>
1518 <div class="line"> </div>
1519 <div class="line"> <span class="keywordtype">id</span> = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_1, NULL, NULL); <span class="comment">// create the thread</span></div>
1520 <div class="line"> <span class="comment">// do something</span></div>
1521 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a>(<span class="keywordtype">id</span>); <span class="comment">// stop the thread</span></div>
1522 <div class="line"> <span class="keywordflow">if</span> (status == <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
1523 <div class="line"> <span class="comment">// Thread was terminated successfully</span></div>
1524 <div class="line"> }</div>
1525 <div class="line"> <span class="keywordflow">else</span> {</div>
1526 <div class="line"> <span class="comment">// Failed to terminate a thread</span></div>
1527 <div class="line"> }</div>
1528 <div class="line">}</div>
1529 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga2f8ba6dba6e9c065a6e236ffd410d74a"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a></div><div class="ttdeci">osStatus_t osThreadTerminate(osThreadId_t thread_id)</div><div class="ttdoc">Terminate execution of a thread.</div></div>
1530 </div><!-- fragment -->
1533 <a id="gab9f8bd715d671c6ee27644867bc1bf65" name="gab9f8bd715d671c6ee27644867bc1bf65"></a>
1534 <h2 class="memtitle"><span class="permalink"><a href="#gab9f8bd715d671c6ee27644867bc1bf65">◆ </a></span>osThreadGetStackSize()</h2>
1536 <div class="memitem">
1537 <div class="memproto">
1538 <table class="memname">
1540 <td class="memname">uint32_t osThreadGetStackSize </td>
1542 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1543 <td class="paramname"><em>thread_id</em></td><td>)</td>
1547 </div><div class="memdoc">
1548 <dl class="params"><dt>Parameters</dt><dd>
1549 <table class="params">
1550 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1554 <dl class="section return"><dt>Returns</dt><dd>stack size in bytes.</dd></dl>
1555 <p>The function <b>osThreadGetStackSize</b> returns the stack size of the thread specified by parameter <em>thread_id</em>. In case of an error, it returns <span class="XML-Token">0</span>.</p>
1556 <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>
1560 <a id="ga9c83bd5dd8de329701775d6ef7012720" name="ga9c83bd5dd8de329701775d6ef7012720"></a>
1561 <h2 class="memtitle"><span class="permalink"><a href="#ga9c83bd5dd8de329701775d6ef7012720">◆ </a></span>osThreadGetStackSpace()</h2>
1563 <div class="memitem">
1564 <div class="memproto">
1565 <table class="memname">
1567 <td class="memname">uint32_t osThreadGetStackSpace </td>
1569 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1570 <td class="paramname"><em>thread_id</em></td><td>)</td>
1574 </div><div class="memdoc">
1575 <dl class="params"><dt>Parameters</dt><dd>
1576 <table class="params">
1577 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1581 <dl class="section return"><dt>Returns</dt><dd>remaining stack space in bytes.</dd></dl>
1582 <p>The function <b>osThreadGetStackSpace</b> returns the size of unused stack space for the thread specified by parameter <em>thread_id</em>. Stack watermark recording during execution needs to be enabled (refer to <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a>). In case of an error, it returns <span class="XML-Token">0</span>.</p>
1583 <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>
1587 <a id="ga495b3f812224e7301f23a691793765db" name="ga495b3f812224e7301f23a691793765db"></a>
1588 <h2 class="memtitle"><span class="permalink"><a href="#ga495b3f812224e7301f23a691793765db">◆ </a></span>osThreadGetCount()</h2>
1590 <div class="memitem">
1591 <div class="memproto">
1592 <table class="memname">
1594 <td class="memname">uint32_t osThreadGetCount </td>
1596 <td class="paramtype">void </td>
1597 <td class="paramname"></td><td>)</td>
1601 </div><div class="memdoc">
1602 <dl class="section return"><dt>Returns</dt><dd>number of active threads.</dd></dl>
1603 <p>The function <b>osThreadGetCount</b> returns the number of active threads or <span class="XML-Token">0</span> in case of an error.</p>
1604 <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>
1608 <a id="ga5606604d56e21ece1a654664be877439" name="ga5606604d56e21ece1a654664be877439"></a>
1609 <h2 class="memtitle"><span class="permalink"><a href="#ga5606604d56e21ece1a654664be877439">◆ </a></span>osThreadEnumerate()</h2>
1611 <div class="memitem">
1612 <div class="memproto">
1613 <table class="memname">
1615 <td class="memname">uint32_t osThreadEnumerate </td>
1617 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> * </td>
1618 <td class="paramname"><em>thread_array</em>, </td>
1621 <td class="paramkey"></td>
1623 <td class="paramtype">uint32_t </td>
1624 <td class="paramname"><em>array_items</em> </td>
1632 </div><div class="memdoc">
1633 <dl class="params"><dt>Parameters</dt><dd>
1634 <table class="params">
1635 <tr><td class="paramdir">[out]</td><td class="paramname">thread_array</td><td>pointer to array for retrieving thread IDs. </td></tr>
1636 <tr><td class="paramdir">[in]</td><td class="paramname">array_items</td><td>maximum number of items in array for retrieving thread IDs. </td></tr>
1640 <dl class="section return"><dt>Returns</dt><dd>number of enumerated threads.</dd></dl>
1641 <p>The function <b>osThreadEnumerate</b> returns the number of enumerated threads or <span class="XML-Token">0</span> in case of an error.</p>
1642 <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>
1646 <a id="ga8f4455b06afb95c1915f15266818a8c6" name="ga8f4455b06afb95c1915f15266818a8c6"></a>
1647 <h2 class="memtitle"><span class="permalink"><a href="#ga8f4455b06afb95c1915f15266818a8c6">◆ </a></span>osThreadFeedWatchdog()</h2>
1649 <div class="memitem">
1650 <div class="memproto">
1651 <table class="memname">
1653 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadFeedWatchdog </td>
1655 <td class="paramtype">uint32_t </td>
1656 <td class="paramname"><em>ticks</em></td><td>)</td>
1660 </div><div class="memdoc">
1661 <dl class="params"><dt>Parameters</dt><dd>
1662 <table class="params">
1663 <tr><td class="paramdir">[in]</td><td class="paramname">ticks</td><td><a class="el" href="theory_of_operation.html#kernelTimer">time ticks</a> value until the thread watchdog expires, or 0 to stop the watchdog </td></tr>
1667 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1668 <p>The function <b>osThreadFeedWatchdog</b> restarts watchdog of the current running thread. If the thread watchdog is not fed again within the <em>ticks</em> interval <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a> will be called.</p>
1669 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1670 <li><em>osOK:</em> the watchdog timer was restarted successfully.</li>
1671 <li><em>osError:</em> cannot be executed (kernel not running).</li>
1672 <li><em>osErrorISR:</em> the function <b>osThreadFeedWatchdog</b> cannot be called from interrupt service routines.</li>
1674 <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>
1675 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1676 <div class="line"> </div>
1677 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) { <span class="comment">// Thread function</span></div>
1678 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// Status of the executed function</span></div>
1679 <div class="line"> :</div>
1680 <div class="line"> <span class="keywordflow">while</span> (1) {</div>
1681 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8f4455b06afb95c1915f15266818a8c6">osThreadFeedWatchdog</a>(500U); <span class="comment">// Feed thread watchdog for 500 ticks</span></div>
1682 <div class="line"> <span class="comment">// verify status value here</span></div>
1683 <div class="line"> :</div>
1684 <div class="line"> }</div>
1685 <div class="line">}</div>
1686 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga8f4455b06afb95c1915f15266818a8c6"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga8f4455b06afb95c1915f15266818a8c6">osThreadFeedWatchdog</a></div><div class="ttdeci">osStatus_t osThreadFeedWatchdog(uint32_t ticks)</div><div class="ttdoc">Feed watchdog of the current running thread.</div></div>
1687 </div><!-- fragment -->
1690 <a id="gaee8e6bed82cd58dad31bb90156182032" name="gaee8e6bed82cd58dad31bb90156182032"></a>
1691 <h2 class="memtitle"><span class="permalink"><a href="#gaee8e6bed82cd58dad31bb90156182032">◆ </a></span>osThreadProtectPrivileged()</h2>
1693 <div class="memitem">
1694 <div class="memproto">
1695 <table class="memname">
1697 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadProtectPrivileged </td>
1699 <td class="paramtype">void </td>
1700 <td class="paramname"></td><td>)</td>
1704 </div><div class="memdoc">
1705 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1706 <p>The function <b>osThreadProtectPrivileged</b> disables creation of new privileged threads. After its successful execution, no new threads with privilege execution mode (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga7c2b7db42d23e4f56132e0ed739d02e5">osThreadPrivileged</a> attribute) can be created. Kernel shall be in ready state or running when <b>osThreadProtectPrivileged</b> is called.</p>
1707 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1708 <li><em>osOK:</em> the creation of new privileged threads is disabled.</li>
1709 <li><em>osError:</em> cannot be executed (kernel not ready).</li>
1710 <li><em>osErrorISR:</em> the function <b>osThreadProtectPrivileged</b> cannot be called from interrupt service routines.</li>
1712 <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>
1713 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1714 <div class="line"> </div>
1715 <div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
1716 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
1717 <div class="line"> :</div>
1718 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>(); <span class="comment">// Initialize CMSIS-RTOS2 kernel</span></div>
1719 <div class="line"> <span class="comment">// verify status value here.</span></div>
1720 <div class="line"> : <span class="comment">// Create privileged threads</span></div>
1721 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee8e6bed82cd58dad31bb90156182032">osThreadProtectPrivileged</a>(); <span class="comment">// Disable creation of new privileged threads.</span></div>
1722 <div class="line"> <span class="comment">// verify status value here.</span></div>
1723 <div class="line"> : <span class="comment">// Start the kernel</span></div>
1724 <div class="line">}</div>
1725 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gaee8e6bed82cd58dad31bb90156182032"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gaee8e6bed82cd58dad31bb90156182032">osThreadProtectPrivileged</a></div><div class="ttdeci">osStatus_t osThreadProtectPrivileged(void)</div><div class="ttdoc">Protect creation of privileged threads.</div></div>
1726 </div><!-- fragment -->
1729 <a id="gadadb56627094dbb07f6aeddf7d713fd9" name="gadadb56627094dbb07f6aeddf7d713fd9"></a>
1730 <h2 class="memtitle"><span class="permalink"><a href="#gadadb56627094dbb07f6aeddf7d713fd9">◆ </a></span>osThreadSuspendClass()</h2>
1732 <div class="memitem">
1733 <div class="memproto">
1734 <table class="memname">
1736 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSuspendClass </td>
1738 <td class="paramtype">uint32_t </td>
1739 <td class="paramname"><em>safety_class</em>, </td>
1742 <td class="paramkey"></td>
1744 <td class="paramtype">uint32_t </td>
1745 <td class="paramname"><em>mode</em> </td>
1753 </div><div class="memdoc">
1754 <dl class="params"><dt>Parameters</dt><dd>
1755 <table class="params">
1756 <tr><td class="paramdir">[in]</td><td class="paramname">safety_class</td><td>safety class. </td></tr>
1757 <tr><td class="paramdir">[in]</td><td class="paramname">mode</td><td>safety mode. </td></tr>
1761 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1762 <p>The function <b>osThreadSuspendClass</b> suspends execution of threads based on safety class assignment. <em>safety_class</em> provides the reference safety class value, while <em>mode</em> is considered as a bitmap that additionally specifies the safety classes to be suspended.</p>
1763 <p>If <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga7abd2d95425d9e02672778b3464b2eaa">osSafetyWithSameClass</a> is set in <em>mode</em> than the threads with safety class value equal to <em>safety_class</em> will be suspended. <br />
1764 If <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga8c77ee126b9215425fc004ee13cdc6de">osSafetyWithLowerClass</a> is set in <em>mode</em> than the threads with safety class value lower than <em>safety_class</em> will be suspended.</p>
1765 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1766 <li><em>osOK:</em> the threads with specified safety class have been suspended successfully.</li>
1767 <li><em>osErrorParameter:</em> <em>safety_class</em> is invalid.</li>
1768 <li><em>osErrorResource:</em> no other <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists.</li>
1769 <li><em>osErrorISR:</em> the function <b>osThreadSuspendClass</b> is called from interrupt other than <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a>.</li>
1770 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class specified by <em>safety_class</em> and <em>mode</em>.</li>
1772 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1773 <div class="line"> </div>
1774 <div class="line"><span class="keywordtype">void</span> SuspendNonCriticalClasses (<span class="keywordtype">void</span>) {</div>
1775 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
1776 <div class="line"> </div>
1777 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gadadb56627094dbb07f6aeddf7d713fd9">osThreadSuspendClass</a>(4U, <a class="code hl_define" href="group__CMSIS__RTOS__Definitions.html#ga7abd2d95425d9e02672778b3464b2eaa">osSafetyWithSameClass</a> | <a class="code hl_define" href="group__CMSIS__RTOS__Definitions.html#ga8c77ee126b9215425fc004ee13cdc6de">osSafetyWithLowerClass</a>); <span class="comment">// Suspends threads with safety class 4 or lower</span></div>
1778 <div class="line"> <span class="comment">// verify status value here.</span></div>
1779 <div class="line">}</div>
1780 <div class="ttc" id="agroup__CMSIS__RTOS__Definitions_html_ga7abd2d95425d9e02672778b3464b2eaa"><div class="ttname"><a href="group__CMSIS__RTOS__Definitions.html#ga7abd2d95425d9e02672778b3464b2eaa">osSafetyWithSameClass</a></div><div class="ttdeci">#define osSafetyWithSameClass</div><div class="ttdoc">Objects with same safety class.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:232</div></div>
1781 <div class="ttc" id="agroup__CMSIS__RTOS__Definitions_html_ga8c77ee126b9215425fc004ee13cdc6de"><div class="ttname"><a href="group__CMSIS__RTOS__Definitions.html#ga8c77ee126b9215425fc004ee13cdc6de">osSafetyWithLowerClass</a></div><div class="ttdeci">#define osSafetyWithLowerClass</div><div class="ttdoc">Objects with lower safety class.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:233</div></div>
1782 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gadadb56627094dbb07f6aeddf7d713fd9"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gadadb56627094dbb07f6aeddf7d713fd9">osThreadSuspendClass</a></div><div class="ttdeci">osStatus_t osThreadSuspendClass(uint32_t safety_class, uint32_t mode)</div><div class="ttdoc">Suspend execution of threads for specified safety classes.</div></div>
1783 </div><!-- fragment -->
1786 <a id="gadd0a06b459925eb5cdeab67b380a3970" name="gadd0a06b459925eb5cdeab67b380a3970"></a>
1787 <h2 class="memtitle"><span class="permalink"><a href="#gadd0a06b459925eb5cdeab67b380a3970">◆ </a></span>osThreadResumeClass()</h2>
1789 <div class="memitem">
1790 <div class="memproto">
1791 <table class="memname">
1793 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadResumeClass </td>
1795 <td class="paramtype">uint32_t </td>
1796 <td class="paramname"><em>safety_class</em>, </td>
1799 <td class="paramkey"></td>
1801 <td class="paramtype">uint32_t </td>
1802 <td class="paramname"><em>mode</em> </td>
1810 </div><div class="memdoc">
1811 <dl class="params"><dt>Parameters</dt><dd>
1812 <table class="params">
1813 <tr><td class="paramdir">[in]</td><td class="paramname">safety_class</td><td>safety class. </td></tr>
1814 <tr><td class="paramdir">[in]</td><td class="paramname">mode</td><td>safety mode. </td></tr>
1818 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1819 <p>The function <b>osThreadResumeClass</b> resumes execution of threads based on safety class assignment. <em>safety_class</em> provides the reference safety class value, while <em>mode</em> is considered as a bitmap that additionally specifies the safety classes to be resumed.</p>
1820 <p>If <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga7abd2d95425d9e02672778b3464b2eaa">osSafetyWithSameClass</a> is set in <em>mode</em> than the threads with safety class value equal to <em>safety_class</em> will be resumed. <br />
1821 If <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga8c77ee126b9215425fc004ee13cdc6de">osSafetyWithLowerClass</a> is set in <em>mode</em> than the threads with safety class value lower than <em>safety_class</em> will be resumed.</p>
1822 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1823 <li><em>osOK:</em> the threads with specified safety class have been resumed successfully.</li>
1824 <li><em>osErrorParameter:</em> <em>safety_class</em> is invalid.</li>
1825 <li><em>osErrorISR:</em> the function <b>osThreadResumeClass</b> is called from interrupt other than <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a>.</li>
1826 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class specified by <em>safety_class</em> and <em>mode</em>.</li>
1828 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1829 <div class="line"> </div>
1830 <div class="line"><span class="keywordtype">void</span> ResumeNonCriticalClasses (<span class="keywordtype">void</span>) {</div>
1831 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
1832 <div class="line"> </div>
1833 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd0a06b459925eb5cdeab67b380a3970">osThreadResumeClass</a>(4U, <a class="code hl_define" href="group__CMSIS__RTOS__Definitions.html#ga7abd2d95425d9e02672778b3464b2eaa">osSafetyWithSameClass</a> | <a class="code hl_define" href="group__CMSIS__RTOS__Definitions.html#ga8c77ee126b9215425fc004ee13cdc6de">osSafetyWithLowerClass</a>); <span class="comment">// Resumes threads with safety class 4 or lower</span></div>
1834 <div class="line"> <span class="comment">// verify status value here.</span></div>
1835 <div class="line">}</div>
1836 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gadd0a06b459925eb5cdeab67b380a3970"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gadd0a06b459925eb5cdeab67b380a3970">osThreadResumeClass</a></div><div class="ttdeci">osStatus_t osThreadResumeClass(uint32_t safety_class, uint32_t mode)</div><div class="ttdoc">Resume execution of threads for specified safety classes.</div></div>
1837 </div><!-- fragment -->
1840 <a id="ga99ce311cc620c65fbac043d04dc7d755" name="ga99ce311cc620c65fbac043d04dc7d755"></a>
1841 <h2 class="memtitle"><span class="permalink"><a href="#ga99ce311cc620c65fbac043d04dc7d755">◆ </a></span>osThreadTerminateZone()</h2>
1843 <div class="memitem">
1844 <div class="memproto">
1845 <table class="memname">
1847 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadTerminateZone </td>
1849 <td class="paramtype">uint32_t </td>
1850 <td class="paramname"><em>zone</em></td><td>)</td>
1854 </div><div class="memdoc">
1855 <dl class="params"><dt>Parameters</dt><dd>
1856 <table class="params">
1857 <tr><td class="paramdir">[in]</td><td class="paramname">zone</td><td>MPU protected zone. </td></tr>
1861 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
1862 <p>The function <b>osThreadTerminateZone</b> terminates execution of threads assigned to the MPU Protected Zone as given by <em>zone</em> parameter.</p>
1863 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
1864 <li><em>osOK:</em> the threads within the specified MPU Protected Zone have been terminated successfully.</li>
1865 <li><em>osErrorParameter:</em> <em>zone</em> is invalid.</li>
1866 <li><em>osErrorResource:</em> no other <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists.</li>
1867 <li><em>osErrorISR:</em> the function <b>osThreadTerminateZone</b> is called from interrupt other than fault.</li>
1868 <li><em>osError:</em> the function <b>osThreadTerminateZone</b> is called from thread.</li>
1870 <dl class="section note"><dt>Note</dt><dd><b>osThreadTerminateZone</b> destroys non-joinable threads and removes their thread IDs from the system. Subsequent access to a terminated thread via its thread ID (for example <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gacc0a98b42f0a5928e12dc91dc76866b9">osThreadGetState</a>) will return an <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820da339313e26613bc12f66a852e2ff8745e">osThreadError</a>. Joinable threads will not be destroyed and return the status <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ggad3dc89e942e38d9f3af858a0269a820dad5b2726c2d0228f4f1a76cf6b630963c">osThreadTerminated</a> until they are joined with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>.</dd></dl>
1871 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1872 <div class="line"> </div>
1873 <div class="line"><span class="keywordtype">void</span> TerminateFaultedThreads (<span class="keywordtype">void</span>) { <span class="comment">// to be called from an exception fault context</span></div>
1874 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
1875 <div class="line"> </div>
1876 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga99ce311cc620c65fbac043d04dc7d755">osThreadTerminateZone</a>(3U); <span class="comment">// Terminates threads assigned to MPU Protected Zone 3</span></div>
1877 <div class="line"> <span class="comment">// verify status value here.</span></div>
1878 <div class="line">}</div>
1879 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga99ce311cc620c65fbac043d04dc7d755"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga99ce311cc620c65fbac043d04dc7d755">osThreadTerminateZone</a></div><div class="ttdeci">osStatus_t osThreadTerminateZone(uint32_t zone)</div><div class="ttdoc">Terminate execution of threads assigned to a specified MPU protected zone.</div></div>
1880 </div><!-- fragment -->
1883 <a id="ga5a02770aaf65c7a3c7562c109884176a" name="ga5a02770aaf65c7a3c7562c109884176a"></a>
1884 <h2 class="memtitle"><span class="permalink"><a href="#ga5a02770aaf65c7a3c7562c109884176a">◆ </a></span>osWatchdogAlarm_Handler()</h2>
1886 <div class="memitem">
1887 <div class="memproto">
1888 <table class="memname">
1890 <td class="memname">uint32_t osWatchdogAlarm_Handler </td>
1892 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> </td>
1893 <td class="paramname"><em>thread_id</em></td><td>)</td>
1897 </div><div class="memdoc">
1898 <dl class="params"><dt>Parameters</dt><dd>
1899 <table class="params">
1900 <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a>. </td></tr>
1904 <dl class="section return"><dt>Returns</dt><dd>new watchdog reload value or 0 to stop the watchdog.</dd></dl>
1905 <p>The callback function <b>osWatchdogAlarm_Handler</b> is called by the kernel when a thread watchdog expires. Parameter <em>thread_id</em> identifies the thread which has the expired thread watchdog. The function needs to be implemented in user application.</p>
1906 <p>Return new reload value to restart the watchdog. Return <span class="XML-Token">0</span> to stop the thread watchdog.</p>
1907 <dl class="section note"><dt>Note</dt><dd>The callback function is called from interrupt.</dd>
1909 When multiple watchdogs expire in the same tick, this function is called for each thread with highest safety class first.</dd></dl>
1910 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div>
1911 <div class="line"> </div>
1912 <div class="line">uint32_t <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a> (<a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id) {</div>
1913 <div class="line"> uint32_t safety_class;</div>
1914 <div class="line"> uint32_t next_interval;</div>
1915 <div class="line"> </div>
1916 <div class="line"> safety_class = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga1bfbef7da94ed4147d231e8d6eeb5f3e">osThreadGetClass</a>(thread_id);</div>
1917 <div class="line"> </div>
1918 <div class="line"> <span class="comment">/* Handle the watchdog depending on how safety-critical is the thread */</span></div>
1919 <div class="line"> <span class="keywordflow">if</span> (safety_class < ...){</div>
1920 <div class="line"> :</div>
1921 <div class="line"> } <span class="keywordflow">else</span> {</div>
1922 <div class="line"> :</div>
1923 <div class="line"> }</div>
1924 <div class="line"> </div>
1925 <div class="line"> <span class="keywordflow">return</span> next_interval;</div>
1926 <div class="line">}</div>
1927 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga1bfbef7da94ed4147d231e8d6eeb5f3e"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga1bfbef7da94ed4147d231e8d6eeb5f3e">osThreadGetClass</a></div><div class="ttdeci">uint32_t osThreadGetClass(osThreadId_t thread_id)</div><div class="ttdoc">Get safety class of a thread.</div></div>
1928 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga5a02770aaf65c7a3c7562c109884176a"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga5a02770aaf65c7a3c7562c109884176a">osWatchdogAlarm_Handler</a></div><div class="ttdeci">uint32_t osWatchdogAlarm_Handler(osThreadId_t thread_id)</div><div class="ttdoc">Handler for expired thread watchdogs.</div></div>
1929 </div><!-- fragment -->
1932 <a id="ga79d4b26de0bfcdaf142f83e585532f93" name="ga79d4b26de0bfcdaf142f83e585532f93"></a>
1933 <h2 class="memtitle"><span class="permalink"><a href="#ga79d4b26de0bfcdaf142f83e585532f93">◆ </a></span>osZoneSetup_Callback()</h2>
1935 <div class="memitem">
1936 <div class="memproto">
1937 <table class="memname">
1939 <td class="memname">void osZoneSetup_Callback </td>
1941 <td class="paramtype">uint32_t </td>
1942 <td class="paramname"><em>zone</em></td><td>)</td>
1946 </div><div class="memdoc">
1947 <dl class="params"><dt>Parameters</dt><dd>
1948 <table class="params">
1949 <tr><td class="paramdir">[in]</td><td class="paramname">zone</td><td>zone number.</td></tr>
1953 <p>The callback function <b>osZoneSetup_Callback</b> is called by the kernel when MPU Protected Zone changes. The function shall be implemented in user application.</p>
1954 <p><b>Code Example:</b> </p><div class="fragment"><div class="line"><span class="comment">/* Update MPU settings for newly activating Zone */</span></div>
1955 <div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga79d4b26de0bfcdaf142f83e585532f93">osZoneSetup_Callback</a> (uint32_t zone) {</div>
1956 <div class="line"> </div>
1957 <div class="line"> <span class="keywordflow">if</span> (zone >= ZONES_NUM) {</div>
1958 <div class="line"> <span class="comment">//Issue an error for incorrect zone value</span></div>
1959 <div class="line"> }</div>
1960 <div class="line"> </div>
1961 <div class="line"> ARM_MPU_Disable();</div>
1962 <div class="line"> ARM_MPU_Load(mpu_table[zone], MPU_REGIONS);</div>
1963 <div class="line"> ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk);</div>
1964 <div class="line">}</div>
1965 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga79d4b26de0bfcdaf142f83e585532f93"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga79d4b26de0bfcdaf142f83e585532f93">osZoneSetup_Callback</a></div><div class="ttdeci">void osZoneSetup_Callback(uint32_t zone)</div><div class="ttdoc">Setup MPU protected zone (called when zone changes).</div></div>
1966 </div><!-- fragment --><p><code>ZONES_NUM</code> is the total amount of zones allocated by the application. For <code>ARM_MPU_</code>... functions refer to <a href="../../Core/html/group__mpu__functions.html"><b>MPU Functions</b></a> in CMSIS-Core documentation. </p>
1970 </div><!-- contents -->
1971 </div><!-- doc-content -->
1972 <!-- start footer part -->
1973 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
1976 <script type="text/javascript">
1978 writeFooter.call(this);