xmclib/CMSIS/Documentation/RTOS/html/systemConfig.html

195 lines
14 KiB
HTML
Raw Normal View History

2024-10-17 17:09:59 +02:00
<!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>System Configuration</title>
<title>CMSIS-RTOS: System Configuration</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-RTOS
&#160;<span id="projectnumber">Version 1.03</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 class="current"><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('systemConfig.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="headertitle">
<div class="title">System Configuration </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The CMSIS-RTOS RTX provides system-wide settings for:</p>
<ul>
<li><a class="el" href="systemConfig.html#RoundRobin">Settings for Round-Robin Thread Switching</a></li>
<li><a class="el" href="systemConfig.html#UserTimer">User Timer Management</a></li>
</ul>
<h1><a class="anchor" id="RoundRobin"></a>
Settings for Round-Robin Thread Switching</h1>
<p>CMSIS-RTOS RTX may be configured to use round-robin multitasking thread switching. Round-robin allows quasi-parallel execution of several threads of the <em>same</em> priority. Threads are not really executed concurrently, but are scheduled where the available CPU time is divided into time slices and CMSIS-RTOS RTX assigns a time slice to each thread. Because the time slice is typically short (only a few milliseconds), it appears as though threads execute simultaneously.</p>
<p>Round-robin thread switching functions as follows:</p>
<ul>
<li>the tick is preloaded with the timeout value when a thread switch occurs</li>
<li>the tick is decremented (if not already zero) each system tick if the same thread is still executing</li>
<li>when the tick reaches 0 it indicates that a timeout has occurred. If there is another thread ready with the <em>same</em> priority, then the system switches to that thread and the tick is preloaded with timeout again.</li>
</ul>
<p>In other words, threads execute for the duration of their time slice (unless a thread's time slice is given up). Then, RTX switches to the next thread that is in <b>READY</b> state and has the same priority. If no other thread with the same priority is ready to run, the current running thread resumes it execution.</p>
<dl class="section note"><dt>Note</dt><dd>When switching to higher priority threads, the round-robin timeout value is reset.</dd></dl>
<p>Round-Robin multitasking is controlled with the <b>#define OS_ROBIN</b>. The time slice period is configured (in RTX Timer ticks) with the <b>#define OS_ROBINTOUT</b>.</p>
<p><b>Code Example:</b></p>
<p>The following example shows a simple CMSIS-RTOS RTX program that uses Round-Robin Multitasking. The two threads in this program are counter loops. RTX starts executing job 1, which is the function named job1. This function creates another task called job2. After job1 executes for its time slice, RTX switches to job2. After job2 executes for its time slice, RTX switches back to job1. This process repeats indefinitely.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os_8h.html">cmsis_os.h</a>&quot;</span> <span class="comment">// CMSIS-RTOS header file</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> counter1;</div>
<div class="line"><span class="keywordtype">int</span> counter2;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> job1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) {</div>
<div class="line"> <span class="keywordflow">while</span> (1) { <span class="comment">// loop forever</span></div>
<div class="line"> counter1++; <span class="comment">// update the counter</span></div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> job2 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg) {</div>
<div class="line"> <span class="keywordflow">while</span> (1) { <span class="comment">// loop forever</span></div>
<div class="line"> counter2++; <span class="comment">// update the counter</span></div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f">osThreadDef</a> (job1, <a class="code" href="cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a>, 1, 0);</div>
<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f">osThreadDef</a> (job2, <a class="code" href="cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a>, 1, 0);</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#ga53d078a801022e202e8115c083ece68e">osKernelInitialize</a> (); <span class="comment">// setup kernel</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> (<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453">osThread</a>(job1), NULL); <span class="comment">// create threads</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> (<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453">osThread</a>(job2), NULL); </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a> (); <span class="comment">// start kernel</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Rather than waiting for a thread time slice to expire, use CMSIS-RTOS functions to signal to the RTX kernel that it can switch to another task. The function <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf13a667493c5d629a90c13e113b99233">osThreadYield</a> passes control to other threads without Round-Robin Multitasking.</dd></dl>
<h1><a class="anchor" id="UserTimer"></a>
User Timer Management</h1>
<p>CMSIS-RTOS RTX supports <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a> which provides timer callback functions. The <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a> is configured with the following <em>#defines:</em> </p>
<table class="doxtable">
<tr>
<th>Name </th><th>#define </th><th>Description </th></tr>
<tr>
<td>User Timers </td><td><code>OS_TIMERS</code> </td><td>Enables the <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a>. When disabled, the <b>osTimerThread</b> is not created. </td></tr>
<tr>
<td>Timer Thread Priority </td><td><code>OS_TIMERPRIO</code> </td><td>Specifies the priority of the osTimerThread that executes the timer callback functions. </td></tr>
<tr>
<td>Timer Thread stack size [bytes] </td><td><code>OS_TIMERSTKSZ</code> </td><td>Specifies the stack size (in words) for the the <b>osTimerThread</b>. </td></tr>
<tr>
<td>Timer Callback Queue size </td><td><code>OS_TIMERCBQS</code> </td><td>Specifies the maximum number of concurrent timer callbacks. </td></tr>
</table>
<dl class="section note"><dt>Note</dt><dd>Refer to <a class="el" href="theory.html#RTX_Threads">CMSIS-RTOS RTX Threads</a> for more information about the <b>osTimerThread</b>.</dd></dl>
<h1><a class="anchor" id="ISRFIFO"></a>
ISR FIFO Queue size</h1>
<p>ISR functions store requests to this buffer, when they are called from the interrupt handler. The default value for <b>#define OS_FIFOSZ</b> is 16. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="rtxImplementation.html">RTX Implementation</a></li><li class="navelem"><a class="el" href="configure.html">Configure RTX</a></li>
<li class="footer">Generated on Wed Feb 8 2017 10:21:02 for CMSIS-RTOS 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>