xmclib/CMSIS/Documentation/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html
2024-10-17 17:09:59 +02:00

1428 lines
114 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Thread Management</title>
<title>CMSIS-RTOS2: Thread Management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="printComponentTabs.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 46px;">
<td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">CMSIS-RTOS2
&#160;<span id="projectnumber">Version 2.1.0</span>
</div>
<div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
<ul class="tablist">
<script type="text/javascript">
<!--
writeComponentTabs.call(this);
//-->
</script>
</ul>
</div>
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
<li><a href="modules.html"><span>Reference</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__CMSIS__RTOS__ThreadMgmt.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Thread Management<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS2 API</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p>Define, create, and control thread functions.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structosThreadAttr__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a></td></tr>
<tr class="memdesc:structosThreadAttr__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attributes structure for thread. <a href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">More...</a><br/></td></tr>
<tr class="separator:structosThreadAttr__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>&#160;&#160;&#160;0x00000001U</td></tr>
<tr class="memdesc:ga249499c519f3f8eef5673009ab6cfcbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread created in joinable state. <a href="#ga249499c519f3f8eef5673009ab6cfcbe">More...</a><br/></td></tr>
<tr class="separator:ga249499c519f3f8eef5673009ab6cfcbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9336c1073858d6b118e2e011636246f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9336c1073858d6b118e2e011636246f">osThreadDetached</a>&#160;&#160;&#160;0x00000000U</td></tr>
<tr class="memdesc:gaa9336c1073858d6b118e2e011636246f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread attributes (attr_bits in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a>). <a href="#gaa9336c1073858d6b118e2e011636246f">More...</a><br/></td></tr>
<tr class="separator:gaa9336c1073858d6b118e2e011636246f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a> )(void *argument)</td></tr>
<tr class="memdesc:gadd51f99a6eb50b94eee75f27cae815eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Entry point of a thread. <a href="#gadd51f99a6eb50b94eee75f27cae815eb">More...</a><br/></td></tr>
<tr class="separator:gadd51f99a6eb50b94eee75f27cae815eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memItemLeft" align="right" valign="top">typedef void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td></tr>
<tr class="separator:gaa6c32fe2a3e0a2e01f212d55b02e51c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gad3dc89e942e38d9f3af858a0269a820d"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> { <br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da7d7d4f719a1be6daa63a251563585fdd">osThreadInactive</a> = 0,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820dad9a040e03d7e7943c0217a3359fc1e8b">osThreadReady</a> = 1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da71dae1f35a4b4d9d2ab24e186461a17f">osThreadRunning</a> = 2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da476cd2370e6938974fb2a79811408819">osThreadBlocked</a> = 3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820dac2a35280d5475f56352c539c9c9b42f9">osThreadTerminated</a> = 4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820dac841e73a7198a42364c9450f1f54a0ef">osThreadError</a> = -1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c">osThreadReserved</a> = 0x7FFFFFFF
<br/>
}</td></tr>
<tr class="memdesc:gad3dc89e942e38d9f3af858a0269a820d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Thread state. <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">More...</a><br/></td></tr>
<tr class="separator:gad3dc89e942e38d9f3af858a0269a820d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> { <br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3">osPriorityNone</a> = 0,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca549e79a43ff4f8b2b31afb613f5caa81">osPriorityIdle</a> = 1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4">osPriorityLow</a> = 8,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe">osPriorityLow1</a> = 8+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507">osPriorityLow2</a> = 8+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50">osPriorityLow3</a> = 8+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81">osPriorityLow4</a> = 8+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353">osPriorityLow5</a> = 8+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393">osPriorityLow6</a> = 8+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a">osPriorityLow7</a> = 8+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a> = 16,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5">osPriorityBelowNormal1</a> = 16+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3">osPriorityBelowNormal2</a> = 16+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf">osPriorityBelowNormal3</a> = 16+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24">osPriorityBelowNormal4</a> = 16+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e">osPriorityBelowNormal5</a> = 16+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05">osPriorityBelowNormal6</a> = 16+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b">osPriorityBelowNormal7</a> = 16+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1">osPriorityNormal</a> = 24,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c">osPriorityNormal1</a> = 24+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205">osPriorityNormal2</a> = 24+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91">osPriorityNormal3</a> = 24+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d">osPriorityNormal4</a> = 24+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab">osPriorityNormal5</a> = 24+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204">osPriorityNormal6</a> = 24+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b">osPriorityNormal7</a> = 24+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a> = 32,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998">osPriorityAboveNormal1</a> = 32+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562">osPriorityAboveNormal2</a> = 32+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013">osPriorityAboveNormal3</a> = 32+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec">osPriorityAboveNormal4</a> = 32+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c">osPriorityAboveNormal5</a> = 32+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207">osPriorityAboveNormal6</a> = 32+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d">osPriorityAboveNormal7</a> = 32+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a> = 40,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb">osPriorityHigh1</a> = 40+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03">osPriorityHigh2</a> = 40+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759">osPriorityHigh3</a> = 40+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb">osPriorityHigh4</a> = 40+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9">osPriorityHigh5</a> = 40+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc">osPriorityHigh6</a> = 40+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652">osPriorityHigh7</a> = 40+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af">osPriorityRealtime</a> = 48,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b">osPriorityRealtime1</a> = 48+1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff">osPriorityRealtime2</a> = 48+2,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa">osPriorityRealtime3</a> = 48+3,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70">osPriorityRealtime4</a> = 48+4,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df">osPriorityRealtime5</a> = 48+5,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194">osPriorityRealtime6</a> = 48+6,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b">osPriorityRealtime7</a> = 48+7,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342eca3943224956e1ea667c6a931c74137b79">osPriorityISR</a> = 56,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4">osPriorityError</a> = -1,
<br/>
&#160;&#160;<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b">osPriorityReserved</a> = 0x7FFFFFFF
<br/>
}</td></tr>
<tr class="memdesc:gad4e3e0971b41f2d17584a8c6837342ec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Priority values. <a href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">More...</a><br/></td></tr>
<tr class="separator:gad4e3e0971b41f2d17584a8c6837342ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</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>
<tr class="memdesc:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a thread and add it to Active Threads. <a href="#ga48d68b8666d99d28fa646ee1d2182b8f">More...</a><br/></td></tr>
<tr class="separator:ga48d68b8666d99d28fa646ee1d2182b8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac3230f3a55a297514b013ebf38f27e0a"><td class="memItemLeft" align="right" valign="top">const char *&#160;</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>
<tr class="memdesc:gac3230f3a55a297514b013ebf38f27e0a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get name of a thread. <a href="#gac3230f3a55a297514b013ebf38f27e0a">More...</a><br/></td></tr>
<tr class="separator:gac3230f3a55a297514b013ebf38f27e0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8df03548e89fbc56402a5cd584a505da"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> (void)</td></tr>
<tr class="memdesc:ga8df03548e89fbc56402a5cd584a505da"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the thread ID of the current running thread. <a href="#ga8df03548e89fbc56402a5cd584a505da">More...</a><br/></td></tr>
<tr class="separator:ga8df03548e89fbc56402a5cd584a505da"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a>&#160;</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>
<tr class="memdesc:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current thread state of a thread. <a href="#gacc0a98b42f0a5928e12dc91dc76866b9">More...</a><br/></td></tr>
<tr class="separator:gacc0a98b42f0a5928e12dc91dc76866b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga861a420fb2d643115b06622903fb3bfb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__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>
<tr class="memdesc:ga861a420fb2d643115b06622903fb3bfb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Change priority of a thread. <a href="#ga861a420fb2d643115b06622903fb3bfb">More...</a><br/></td></tr>
<tr class="separator:ga861a420fb2d643115b06622903fb3bfb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a>&#160;</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>
<tr class="memdesc:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current priority of a thread. <a href="#ga0aeaf349604f456e68e78f9d3b42e44b">More...</a><br/></td></tr>
<tr class="separator:ga0aeaf349604f456e68e78f9d3b42e44b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad01c7ec26535b1de6b018bb9466720e2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (void)</td></tr>
<tr class="memdesc:gad01c7ec26535b1de6b018bb9466720e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pass control to next thread that is in state <b>READY</b>. <a href="#gad01c7ec26535b1de6b018bb9466720e2">More...</a><br/></td></tr>
<tr class="separator:gad01c7ec26535b1de6b018bb9466720e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa9de419d0152bf77e9bbcd1f369fb990">osThreadSuspend</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="mdescLeft">&#160;</td><td class="mdescRight">Suspend execution of a thread. <a href="#gaa9de419d0152bf77e9bbcd1f369fb990">More...</a><br/></td></tr>
<tr class="separator:gaa9de419d0152bf77e9bbcd1f369fb990"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3dbad90eff394b02de76a452c84c5d80"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga3dbad90eff394b02de76a452c84c5d80"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resume execution of a thread. <a href="#ga3dbad90eff394b02de76a452c84c5d80">More...</a><br/></td></tr>
<tr class="separator:ga3dbad90eff394b02de76a452c84c5d80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaaad14cd9547341ea8109dc4e8540f1dc">osThreadDetach</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Detach a thread (thread storage can be reclaimed when thread terminates). <a href="#gaaad14cd9547341ea8109dc4e8540f1dc">More...</a><br/></td></tr>
<tr class="separator:gaaad14cd9547341ea8109dc4e8540f1dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga3fca90fb0679afeb968aa8c3d5874487"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for specified thread to terminate. <a href="#ga3fca90fb0679afeb968aa8c3d5874487">More...</a><br/></td></tr>
<tr class="separator:ga3fca90fb0679afeb968aa8c3d5874487"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaddaa452dd7610e4096647a566d3556fc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a> (void)</td></tr>
<tr class="memdesc:gaddaa452dd7610e4096647a566d3556fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminate execution of current running thread. <a href="#gaddaa452dd7610e4096647a566d3556fc">More...</a><br/></td></tr>
<tr class="separator:gaddaa452dd7610e4096647a566d3556fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> (<a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> thread_id)</td></tr>
<tr class="memdesc:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminate execution of a thread. <a href="#ga2f8ba6dba6e9c065a6e236ffd410d74a">More...</a><br/></td></tr>
<tr class="separator:ga2f8ba6dba6e9c065a6e236ffd410d74a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</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>
<tr class="memdesc:gab9f8bd715d671c6ee27644867bc1bf65"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get stack size of a thread. <a href="#gab9f8bd715d671c6ee27644867bc1bf65">More...</a><br/></td></tr>
<tr class="separator:gab9f8bd715d671c6ee27644867bc1bf65"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9c83bd5dd8de329701775d6ef7012720"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</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>
<tr class="memdesc:ga9c83bd5dd8de329701775d6ef7012720"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get available stack space of a thread based on stack watermark recording during execution. <a href="#ga9c83bd5dd8de329701775d6ef7012720">More...</a><br/></td></tr>
<tr class="separator:ga9c83bd5dd8de329701775d6ef7012720"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga495b3f812224e7301f23a691793765db"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga495b3f812224e7301f23a691793765db">osThreadGetCount</a> (void)</td></tr>
<tr class="memdesc:ga495b3f812224e7301f23a691793765db"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of active threads. <a href="#ga495b3f812224e7301f23a691793765db">More...</a><br/></td></tr>
<tr class="separator:ga495b3f812224e7301f23a691793765db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5606604d56e21ece1a654664be877439"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</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>
<tr class="memdesc:ga5606604d56e21ece1a654664be877439"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enumerate active threads. <a href="#ga5606604d56e21ece1a654664be877439">More...</a><br/></td></tr>
<tr class="separator:ga5606604d56e21ece1a654664be877439"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The Thread Management function group allows defining, creating, and controlling thread functions in the system.</p>
<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>
<p><a class="anchor" id="ThreadStates"></a></p>
<h2>Thread states </h2>
<p>Threads can be in the following states:</p>
<ul>
<li><b>RUNNING:</b> The thread that is currently running is in the <b>RUNNING</b> state. Only one thread at a time can be in this state.</li>
<li><b>READY:</b> Threads which are ready to run are in the <b>READY</b> state. Once the <b>RUNNING</b> thread has terminated, or is <b>BLOCKED</b>, the next <b>READY</b> thread with the highest priority becomes the <b>RUNNING</b> thread.</li>
<li><b>BLOCKED:</b> Threads that are blocked either delayed, waiting for an event to occur or suspended are in the <b>BLOCKED</b> state.</li>
<li><b>TERMINATED:</b> When <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> is called, threads are <b>TERMINATED</b> with resources not yet released.</li>
<li><b>INACTIVE:</b> Threads that are not created or have been terminated with all resources released are in the <b>INACTIVE</b> state.</li>
</ul>
<div class="image">
<img src="ThreadStatus.png" alt="ThreadStatus.png"/>
<div class="caption">
Thread State and State Transitions</div></div>
<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>
<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 <b>READY</b> or <b>RUNNING</b> state (depending on the thread priority).</li>
<li>CMSIS-RTOS is pre-emptive. The active thread with the highest priority becomes the <b>RUNNING</b> 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>
<li>The <b>RUNNING</b> thread transfers into the <b>BLOCKED</b> state when it is delayed, waiting for an event or suspended.</li>
<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 <b>INACTIVE</b> state and typically do not consume any dynamic memory resources.</li>
</ul>
<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>
<h1>Thread Examples </h1>
<p>The following examples show various scenarios to create threads:</p>
<p><b>Example 1 - Create a simple thread</b></p>
<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>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>();</div>
<div class="line"> ;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, NULL); <span class="comment">// Create thread with default settings</span></div>
<div class="line"> ;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>(); </div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 2 - Create thread with stack non-default stack size</b></p>
<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>
<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 osThreadNew.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line"> .<a class="code" 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>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line"> ; </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr); <span class="comment">// Create thread with custom sized stack memory</span></div>
<div class="line"> ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 3 - Create thread with statically allocated stack</b></p>
<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>
<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>
<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 osThreadNew.</p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> uint64_t thread1_stk_1[64];</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line"> .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ad7c9b42355a4c8b9467130ab3fb19e43">stack_mem</a> = &amp;thread1_stk_1[0],</div>
<div class="line"> .stack_size = <span class="keyword">sizeof</span>(thread1_stk_1)</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line"> ; </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr); <span class="comment">// Create thread with statically allocated stack memory</span></div>
<div class="line"> ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 4 - Thread with statically allocated task control block</b></p>
<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 &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//include rtx_os.h for types of RTX objects</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="rtx__os_8h.html">rtx_os.h</a>&quot;</span></div>
<div class="line"></div>
<div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> thread1_tcb;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line"> .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a> = &amp;thread1_tcb,</div>
<div class="line"> .cb_size = <span class="keyword">sizeof</span>(thread1_tcb),</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line"> ;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr); <span class="comment">// Create thread with custom tcb memory</span></div>
<div class="line"> ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 5 - Create thread with a different priority</b></p>
<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>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> thread1_attr = {</div>
<div class="line"> .<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a6a5183df4c54c3e28dc8dc704f2487d5">priority</a> = <a class="code" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2">osPriorityHigh</a> <span class="comment">//Set initial thread priority to high </span></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line"> ;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(thread1, NULL, &amp;thread1_attr); </div>
<div class="line"> ;</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example 6 - Joinable threads</b></p>
<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>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) { </div>
<div class="line"> ; <span class="comment">// work a lot on data[] </span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000); </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> thread1 (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> worker_attr;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> worker_ids[4];</div>
<div class="line"> uint8_t data[4][10];</div>
<div class="line"></div>
<div class="line"> memset(&amp;worker_attr, 0, <span class="keyword">sizeof</span>(worker_attr));</div>
<div class="line"> worker_attr.<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#a6e93b49cb79c12f768d72580c7731f30">attr_bits</a> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>;</div>
<div class="line"> </div>
<div class="line"> worker_ids[0] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[0][0], &amp;worker_attr); </div>
<div class="line"> worker_ids[1] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[1][0], &amp;worker_attr); </div>
<div class="line"> worker_ids[2] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[2][0], &amp;worker_attr); </div>
<div class="line"> worker_ids[3] = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;data[3][0], &amp;worker_attr); </div>
<div class="line"> </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[0]);</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[1]);</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[2]);</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>(worker_ids[3]);</div>
<div class="line"> </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>(); </div>
<div class="line">}</div>
</div><!-- fragment --> <hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structosThreadAttr__t" id="structosThreadAttr__t"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct osThreadAttr_t</td>
</tr>
</table>
</div><div class="memdoc">
<div class="textblock"></div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
<td class="fieldname">
name</td>
<td class="fielddoc">
name of the thread <p>String with a human readable name of the thread object. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
<td class="fieldname">
attr_bits</td>
<td class="fielddoc">
attribute bits <p>The following predefined bit masks can be assigned to set options for a thread object.</p>
<table class="doxtable">
<tr>
<th align="left">Bit Mask </th><th align="left">Description </th></tr>
<tr>
<td align="left">osThreadJoinable </td><td align="left">Thread is created in a join-able state. </td></tr>
<tr>
<td align="left">osThreadDetached </td><td align="left">Thread is created in a detached state (default). </td></tr>
</table>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
<td class="fieldname">
cb_mem</td>
<td class="fielddoc">
memory for control block <p>Pointer to a memory location for the thread object. This can optionally be used for custom memory management systems. Specify <span class="XML-Token">NULL</span> to use the kernel memory management. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
<td class="fieldname">
cb_size</td>
<td class="fielddoc">
size of provided memory for control block <p>The size of the memory block passed with <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. Must be the size of a thread control block object or larger. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ad7c9b42355a4c8b9467130ab3fb19e43"></a>void *</td>
<td class="fieldname">
stack_mem</td>
<td class="fielddoc">
memory for stack <p>Pointer to a memory location for the thread stack. This can optionally be used for custom memory management systems. Specify <span class="XML-Token">NULL</span> to use the kernel memory management. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aacbc9a219f2d6870e9ce89bb93f975c9"></a>uint32_t</td>
<td class="fieldname">
stack_size</td>
<td class="fielddoc">
size of stack <p>The size of the stack in Bytes. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a6a5183df4c54c3e28dc8dc704f2487d5"></a><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
<td class="fieldname">
priority</td>
<td class="fielddoc">
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>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a697f2aad6119d655d212ea10245ae394"></a><a class="el" href="cmsis__os2_8h.html#ad5ef21485fe5f60263bc0b48006202cb">TZ_ModuleId_t</a></td>
<td class="fieldname">
tz_module</td>
<td class="fielddoc">
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. See <a href="../../Core/html/group__context__trustzone__functions.html">TrustZone RTOS Context Management</a>. </p>
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a66f538babc389986738ec70104e0562b"></a>uint32_t</td>
<td class="fieldname">
reserved</td>
<td class="fielddoc">
reserved (must be 0) <p>Reserved for future use. Must be <span class="XML-Token">0</span>. </p>
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga249499c519f3f8eef5673009ab6cfcbe"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define osThreadJoinable&#160;&#160;&#160;0x00000001U</td>
</tr>
</table>
</div><div class="memdoc">
<p>See <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>
</div>
</div>
<a class="anchor" id="gaa9336c1073858d6b118e2e011636246f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define osThreadDetached&#160;&#160;&#160;0x00000000U</td>
</tr>
</table>
</div><div class="memdoc">
<p>Thread created in detached state (default)</p>
<p>A thread in this state cannot be joined using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3fca90fb0679afeb968aa8c3d5874487">osThreadJoin</a>. </p>
</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="gadd51f99a6eb50b94eee75f27cae815eb"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void(* osThreadFunc_t)(void *argument)</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="gaa6c32fe2a3e0a2e01f212d55b02e51c7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Thread ID identifies the thread. </p>
</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a></td>
</tr>
</table>
</div><div class="memdoc">
<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>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820da7d7d4f719a1be6daa63a251563585fdd"></a>osThreadInactive</em>&#160;</td><td class="fielddoc">
<p>Inactive. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820dad9a040e03d7e7943c0217a3359fc1e8b"></a>osThreadReady</em>&#160;</td><td class="fielddoc">
<p>Ready. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820da71dae1f35a4b4d9d2ab24e186461a17f"></a>osThreadRunning</em>&#160;</td><td class="fielddoc">
<p>Running. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820da476cd2370e6938974fb2a79811408819"></a>osThreadBlocked</em>&#160;</td><td class="fielddoc">
<p>Blocked. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820dac2a35280d5475f56352c539c9c9b42f9"></a>osThreadTerminated</em>&#160;</td><td class="fielddoc">
<p>Terminated. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820dac841e73a7198a42364c9450f1f54a0ef"></a>osThreadError</em>&#160;</td><td class="fielddoc">
<p>Error. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad3dc89e942e38d9f3af858a0269a820da8872f7e352370eb11ee772c7dcca6e6c"></a>osThreadReserved</em>&#160;</td><td class="fielddoc">
<p>Prevents enum down-size compiler optimization. </p>
</td></tr>
</table>
</div>
</div>
<a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ec"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>The <b>osPriority_t</b> value specifies the priority for a thread. The default thread priority should be <em>osPriorityNormal</em>. If a Thread is active that has a higher priority than the currently executing thread, then a thread switch occurs immediately to execute the new task.</p>
<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.</p>
<dl class="section note"><dt>Note</dt><dd>Priority inheritance only applies to mutexes. </dd></dl>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca6c437c7185161a3bd1e7e4669dfa17a3"></a>osPriorityNone</em>&#160;</td><td class="fielddoc">
<p>No priority (not initialized). </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca549e79a43ff4f8b2b31afb613f5caa81"></a>osPriorityIdle</em>&#160;</td><td class="fielddoc">
<p>Reserved for Idle thread. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca61cb822239ac8f66dfbdc7291598a3d4"></a>osPriorityLow</em>&#160;</td><td class="fielddoc">
<p>Priority: low. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaba2b6919f0b630c8c1b2c940e3bfadbe"></a>osPriorityLow1</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca78ad5d00aa07a2b4bf30a639544f5507"></a>osPriorityLow2</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca28ccb07942c16f5f5efefb6cf68a7f50"></a>osPriorityLow3</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5a4a4f26d5b220a968e221e854f69a81"></a>osPriorityLow4</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecad69b8c14809bc5bdce4887f5a57d9353"></a>osPriorityLow5</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecac0f188468664d06d4cd9e6e1ed351393"></a>osPriorityLow6</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5b151ebba7fdeb1baaa9b7b420890b7a"></a>osPriorityLow7</em>&#160;</td><td class="fielddoc">
<p>Priority: low + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6"></a>osPriorityBelowNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca9138da7187690b15f52d8e5729c18da5"></a>osPriorityBelowNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca4f081d6735bf2f513338b07eddf13ae3"></a>osPriorityBelowNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca19c013690d0d6bf3ac90707942be3fdf"></a>osPriorityBelowNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca36931ad6cee5e4700e2c8622bdd2cd24"></a>osPriorityBelowNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca0bcd9ad1e7a02e3bf03be7dcc8ece38e"></a>osPriorityBelowNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecabd3cc7df5b92b752ddf1e7843a786c05"></a>osPriorityBelowNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecab18e3bda7b5e418e309a62d6267ea14b"></a>osPriorityBelowNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: below normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca45a2895ad30c79fb97de18cac7cc19f1"></a>osPriorityNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca3e70c19e03d5a54e66bd071f0776782c"></a>osPriorityNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca19e96f2b025b6462a43b1965043c8205"></a>osPriorityNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca402bd7ab26fb57c8cee8cf94168f4c91"></a>osPriorityNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca93ef07d3a107aeee6508bfd29ba3485d"></a>osPriorityNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca68f3f6fdaa639de300277802aa13a0ab"></a>osPriorityNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca8221eb0d059726a6309f1f2d0cdb6204"></a>osPriorityNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca049abd04f8951415407ec9d92bd9b80b"></a>osPriorityNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b"></a>osPriorityAboveNormal</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecabfeafc713edfc7b9130aa5c762d68998"></a>osPriorityAboveNormal1</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca901acf86070e06f5990b611734ee2562"></a>osPriorityAboveNormal2</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecad566b876b64e6efdc3eba0fc04e54013"></a>osPriorityAboveNormal3</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca6ccac37d7dae4586a2031966d36a63ec"></a>osPriorityAboveNormal4</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecae36e8b38ee046a3104bcccabb10cf78c"></a>osPriorityAboveNormal5</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca61e6ce27e1e0f34f2540b413b8a8b207"></a>osPriorityAboveNormal6</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecadbbb0fed3ada6b9b50d4a628abc2a67d"></a>osPriorityAboveNormal7</em>&#160;</td><td class="fielddoc">
<p>Priority: above normal + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca914433934143a9ba767e59577c56e6c2"></a>osPriorityHigh</em>&#160;</td><td class="fielddoc">
<p>Priority: high. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca17b7a7e6febf12444a84e90edfce36cb"></a>osPriorityHigh1</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca40a120cf8bbc42e575455c027f3d9b03"></a>osPriorityHigh2</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca0b15518b0b5321a29efa0b42b2f8c759"></a>osPriorityHigh3</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecafe5a4f393fab04551ac7d93e80cdf0fb"></a>osPriorityHigh4</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5960841bfbdd959b163429e8502ea4e9"></a>osPriorityHigh5</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca5714dda6effc1a3f8ec155d97e3e69bc"></a>osPriorityHigh6</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca63ad0cc52a701ef3d9df52b59b995652"></a>osPriorityHigh7</em>&#160;</td><td class="fielddoc">
<p>Priority: high + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca1485dec3702434a1ec3cb74c7a17a4af"></a>osPriorityRealtime</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaf685a06b30f0635476e21347a986305b"></a>osPriorityRealtime1</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 1. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecab832bd9de84e5eec2ecad69d085dadff"></a>osPriorityRealtime2</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 2. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca3f2261e5e733e92844ae8c630f2f9eaa"></a>osPriorityRealtime3</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 3. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaf614e3dc966d559cd9d9d2a0f78ebe70"></a>osPriorityRealtime4</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 4. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaff84f31ceff203c711fb9476443507df"></a>osPriorityRealtime5</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 5. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca80ae9d0dd256312c0c8f44af48316194"></a>osPriorityRealtime6</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 6. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecaa76da6825c4bd31c4958200bc289103b"></a>osPriorityRealtime7</em>&#160;</td><td class="fielddoc">
<p>Priority: realtime + 7. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342eca3943224956e1ea667c6a931c74137b79"></a>osPriorityISR</em>&#160;</td><td class="fielddoc">
<p>Reserved for ISR deferred thread. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecae35f5e2f9c64ad346822521b643bdea4"></a>osPriorityError</em>&#160;</td><td class="fielddoc">
<p>System cannot determine priority or illegal priority. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="gad4e3e0971b41f2d17584a8c6837342ecac86c171f8d466cced0cb1b03bb03343b"></a>osPriorityReserved</em>&#160;</td><td class="fielddoc">
<p>Prevents enum down-size compiler optimization. </p>
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga48d68b8666d99d28fa646ee1d2182b8f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadNew </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gadd51f99a6eb50b94eee75f27cae815eb">osThreadFunc_t</a>&#160;</td>
<td class="paramname"><em>func</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>argument</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *&#160;</td>
<td class="paramname"><em>attr</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">func</td><td>thread function. </td></tr>
<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>
<tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>thread attributes; NULL: default values. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
<p>The function <b>osThreadNew</b> starts a thread function by adding it to the list of active threads and sets it to state <b>READY</b>. 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 <b>RUNNING</b> thread, the created thread function starts instantly and becomes the new <b>RUNNING</b> thread. Thread attributes are defined with the parameter pointer <em>attr</em>. Attributes include settings for thread priority, stack size, or memory allocation.</p>
<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>
<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>
</div>
</div>
<a class="anchor" id="gac3230f3a55a297514b013ebf38f27e0a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char * osThreadGetName </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>name as NULL terminated string.</dd></dl>
<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>
<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>
<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>
<div class="line"> <span class="keywordtype">char</span> id; <span class="comment">// id for the currently running thread</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac3230f3a55a297514b013ebf38f27e0a">osThreadGetName</a> ();</div>
<div class="line"> <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == NULL) {</div>
<div class="line"> <span class="comment">// Failed to get the thread name; not in a thread</span></div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga8df03548e89fbc56402a5cd584a505da"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> osThreadGetId </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>thread ID for reference by other functions or NULL in case of error.</dd></dl>
<p>The function <b>osThreadGetId</b> returns the thread object ID of the currently running thread or NULL in case of an error.</p>
<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>
<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>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> ();</div>
<div class="line"> <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == NULL) {</div>
<div class="line"> <span class="comment">// Failed to get the id; not in a thread</span></div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gacc0a98b42f0a5928e12dc91dc76866b9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad3dc89e942e38d9f3af858a0269a820d">osThreadState_t</a> osThreadGetState </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>current thread state of the specified thread.</dd></dl>
<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>
<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>
</div>
</div>
<a class="anchor" id="ga861a420fb2d643115b06622903fb3bfb"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSetPriority </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a>&#160;</td>
<td class="paramname"><em>priority</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
<tr><td class="paramdir">[in]</td><td class="paramname">priority</td><td>new priority value for the thread function. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<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>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the priority of the specified thread has been changed successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid or <em>priority</em> is incorrect.</li>
<li><em>osErrorResource:</em> thread specified by parameter <em>thread_id</em> is in an invalid thread state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadSetPriority</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<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>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// status of the executed function</span></div>
<div class="line"> </div>
<div class="line"> : </div>
<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> (); <span class="comment">// Obtain ID of current running thread</span></div>
<div class="line"> </div>
<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga861a420fb2d643115b06622903fb3bfb">osThreadSetPriority</a> (<span class="keywordtype">id</span>, <a class="code" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca193b650117c209b4a203954542bcc3e6">osPriorityBelowNormal</a>); <span class="comment">// Set thread priority</span></div>
<div class="line"> <span class="keywordflow">if</span> (status == <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line"> <span class="comment">// Thread priority changed to BelowNormal</span></div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="comment">// Failed to set the priority</span></div>
<div class="line"> }</div>
<div class="line"> : </div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga0aeaf349604f456e68e78f9d3b42e44b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> osThreadGetPriority </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>current priority value of the specified thread.</dd></dl>
<p>The function <b>osThreadGetPriority</b> returns the priority of an active thread specified by the parameter <em>thread_id</em>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> return values:</p>
<ul>
<li><em>priority:</em> the priority of the specified thread.</li>
<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>
</ul>
<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>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<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>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id; <span class="comment">// id for the currently running thread</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad4e3e0971b41f2d17584a8c6837342ec">osPriority_t</a> priority; <span class="comment">// thread priority</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga8df03548e89fbc56402a5cd584a505da">osThreadGetId</a> (); <span class="comment">// Obtain ID of current running thread</span></div>
<div class="line"> priority = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga0aeaf349604f456e68e78f9d3b42e44b">osThreadGetPriority</a> (<span class="keywordtype">id</span>); <span class="comment">// Obtain the thread priority</span></div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gad01c7ec26535b1de6b018bb9466720e2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadYield </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadYield</b> passes control to the next thread that is in the <b>READY</b> state. If there is no other thread in state <b>READY</b>, then the current thread continues execution and no thread switching occurs.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> control has been passed to the next thread successfully.</li>
<li><em>osError:</em> an unspecified error has occurred.</li>
<li><em>osErrorISR:</em> the function <b>osThreadYield</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<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>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// status of the executed function</span></div>
<div class="line"> :</div>
<div class="line"> <span class="keywordflow">while</span> (1) {</div>
<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>(); <span class="comment">// </span></div>
<div class="line"> <span class="keywordflow">if</span> (status != <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line"> <span class="comment">// an error occurred</span></div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gaa9de419d0152bf77e9bbcd1f369fb990"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadSuspend </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<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 <em>BLOCKED</em> state (<a class="el" href="cmsis__os2_8h.html#gad3dc89e942e38d9f3af858a0269a820da476cd2370e6938974fb2a79811408819">osThreadBlocked</a>). The thread is not executed until restarted with the function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga3dbad90eff394b02de76a452c84c5d80">osThreadResume</a>. Threads that are already <em>BLOCKED</em> are suspended and become ready after they are resumed.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the thread has been suspended successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> thread specified by parameter <em>thread_id</em> is in an invalid thread state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadSuspend</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
</div>
</div>
<a class="anchor" id="ga3dbad90eff394b02de76a452c84c5d80"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadResume </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<p>The function <b>osThreadResume</b> forces a thread (specified with <em>thread_id</em>) in <em>BLOCKED</em> state to resume operation.</p>
<p>Functions that will put a thread into <em>BLOCKED</em> 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#gaf0763875335699a9baa704ee36990d3c">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>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the thread has been resumed successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> thread specified by parameter <em>thread_id</em> is in an invalid thread state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadResume</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
</div>
</div>
<a class="anchor" id="gaaad14cd9547341ea8109dc4e8540f1dc"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadDetach </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<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>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the attribute of the specified thread has been changed to detached successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> thread specified by parameter <em>thread_id</em> is in an invalid thread state.</li>
<li><em>osErrorISR:</em> the function <b>osThreadDetach</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
</div>
</div>
<a class="anchor" id="ga3fca90fb0679afeb968aa8c3d5874487"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadJoin </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<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#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<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>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> parameter <em>thread_id</em> is <span class="XML-Token">NULL</span> or refers to a thread that is not an active thread or the thread is not joinable.</li>
<li><em>osErrorISR:</em> the function <b>osThreadJoin</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
</div>
</div>
<a class="anchor" id="gaddaa452dd7610e4096647a566d3556fc"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> void osThreadExit </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<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>
<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>
<p><b>Code</b> <b>Example</b> </p>
<div class="fragment"><div class="line"><a class="code" href="cmsis__os2_8h.html#a153a4a31b276a9758959580538720a51">__NO_RETURN</a> <span class="keywordtype">void</span> worker (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> <span class="comment">// do something</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000);</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaddaa452dd7610e4096647a566d3556fc">osThreadExit</a>();</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga2f8ba6dba6e9c065a6e236ffd410d74a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osThreadTerminate </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
<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 <b>RUNNING</b>, the thread terminates and the execution continues with the next <b>READY</b> thread. If no such thread exists, the function will not terminate the running thread, but return <em>osErrorResource</em>.</p>
<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
<ul>
<li><em>osOK:</em> the specified thread has been removed from the active thread list successfully.</li>
<li><em>osErrorParameter:</em> <em>thread_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
<li><em>osErrorResource:</em> thread specified by parameter <em>thread_id</em> is in an invalid thread state or no other <b>READY</b> thread exists.</li>
<li><em>osErrorISR:</em> the function <b>osThreadTerminate</b> cannot be called from interrupt service routines.</li>
</ul>
<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>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<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>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> ThreadTerminate_example (<span class="keywordtype">void</span>) {</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> id;</div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (Thread_1, NULL, NULL); <span class="comment">// create the thread</span></div>
<div class="line"> <span class="comment">// do something</span></div>
<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga2f8ba6dba6e9c065a6e236ffd410d74a">osThreadTerminate</a> (<span class="keywordtype">id</span>); <span class="comment">// stop the thread</span></div>
<div class="line"> <span class="keywordflow">if</span> (status == <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div>
<div class="line"> <span class="comment">// Thread was terminated successfully</span></div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="comment">// Failed to terminate a thread</span></div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gab9f8bd715d671c6ee27644867bc1bf65"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t osThreadGetStackSize </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>stack size in bytes.</dd></dl>
<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>
<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>
</div>
</div>
<a class="anchor" id="ga9c83bd5dd8de329701775d6ef7012720"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t osThreadGetStackSpace </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a>&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>remaining stack space in bytes.</dd></dl>
<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>
<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>
</div>
</div>
<a class="anchor" id="ga495b3f812224e7301f23a691793765db"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t osThreadGetCount </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>number of active threads.</dd></dl>
<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>
<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>
</div>
</div>
<a class="anchor" id="ga5606604d56e21ece1a654664be877439"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t osThreadEnumerate </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> *&#160;</td>
<td class="paramname"><em>thread_array</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>array_items</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[out]</td><td class="paramname">thread_array</td><td>pointer to array for retrieving thread IDs. </td></tr>
<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>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of enumerated threads.</dd></dl>
<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>
<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>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Wed Feb 8 2017 10:21:04 for CMSIS-RTOS2 by ARM Ltd. All rights reserved.
<!--
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
-->
</li>
</ul>
</div>
</body>
</html>