<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Labor04: xTaskCreateRestricted</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</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: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Labor04
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></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">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__x_task_create_restricted.html',''); initResizable(); });
/* @license-end */
</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)">
</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">xTaskCreateRestricted</div>  </div>
</div><!--header-->
<div class="contents">
<p>task. h </p><pre>
 BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );</pre><p>Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.</p>
<p>xTaskCreateRestricted() should only be used in systems that include an MPU implementation.</p>
<p>Create a new task and add it to the list of tasks that are ready to run. The function parameters define the memory regions and associated access permissions allocated to the task.</p>
<p>See xTaskCreateRestrictedStatic() for a version that does not use any dynamic memory allocation.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pxTaskDefinition</td><td>Pointer to a structure that contains a member for each of the normal xTaskCreate() parameters (see the xTaskCreate() API documentation) plus an optional stack buffer and the memory region definitions.</td></tr>
    <tr><td class="paramname">pxCreatedTask</td><td>Used to pass back a handle by which the created task can be referenced.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pdPASS if the task was successfully created and added to a ready list, otherwise an error code defined in the file <a class="el" href="projdefs_8h.html">projdefs.h</a></dd></dl>
<p>Example usage: </p><pre>
// Create an TaskParameters_t structure that defines the task to be created.
static const TaskParameters_t xCheckTaskParameters =
{
    vATask,     // pvTaskCode - the function that implements the task.
    "ATask",    // pcName - just a text name for the task to assist debugging.
    100,        // usStackDepth - the stack size DEFINED IN WORDS.
    NULL,       // pvParameters - passed into the task function as the function parameters.
    ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
    cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.</pre><pre>    // xRegions - Allocate up to three separate memory regions for access by
    // the task, with appropriate access permissions.  Different processors have
    // different memory alignment requirements - refer to the FreeRTOS documentation
    // for full information.
    {
        // Base address                 Length  Parameters
        { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
        { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
        { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
    }
};</pre><pre>int <a class="el" href="_main_8c.html#a840291bc02cba5474a4cb46a9b9566fe" title="app entry point">main( void )</a>
{
TaskHandle_t xHandle;</pre><pre>    // Create a task from the const structure defined above.  The task handle
    // is requested (the second parameter is not NULL) but in this case just for
    // demonstration purposes as its not actually used.
    xTaskCreateRestricted( &amp;xRegTest1Parameters, &amp;xHandle );</pre><pre>    // Start the scheduler.
    <a class="el" href="task_8h.html#aaf9dca1065c60abdeb309d56ab7293cb">vTaskStartScheduler()</a>;</pre><pre>    // Will only get here if there was insufficient memory to create the idle
    // and/or timer task.
    for( ;; );
}
   </pre><p>task. h </p><pre>
 void <a class="el" href="task_8h.html#ad889595baff9faf9efe02f3696825409">vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions )</a>;</pre><p>Memory regions are assigned to a restricted task when the task is created by a call to xTaskCreateRestricted(). These regions can be redefined using <a class="el" href="task_8h.html#ad889595baff9faf9efe02f3696825409">vTaskAllocateMPURegions()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">xTask</td><td>The handle of the task being updated.</td></tr>
    <tr><td class="paramname">xRegions</td><td>A pointer to an MemoryRegion_t structure that contains the new memory region definitions.</td></tr>
  </table>
  </dd>
</dl>
<p>Example usage: </p><pre>
// Define an array of MemoryRegion_t structures that configures an MPU region
// allowing read/write access for 1024 bytes starting at the beginning of the
// ucOneKByte array.  The other two of the maximum 3 definable regions are
// unused so set to zero.
static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
{
    // Base address     Length      Parameters
    { ucOneKByte,       1024,       portMPU_REGION_READ_WRITE },
    { 0,                0,          0 },
    { 0,                0,          0 }
};</pre><pre>void vATask( void *pvParameters )
{
    // This task was created such that it has access to certain regions of
    // memory as defined by the MPU configuration.  At some point it is
    // desired that these MPU regions are replaced with that defined in the
    // xAltRegions const struct above.  Use a call to <a class="el" href="task_8h.html#ad889595baff9faf9efe02f3696825409">vTaskAllocateMPURegions()</a>
    // for this purpose.  NULL is used as the task handle to indicate that this
    // function should modify the MPU regions of the calling task.
    vTaskAllocateMPURegions( NULL, xAltRegions );</pre><pre>    // Now the task can continue its function, but from this point on can only
    // access its stack and the ucOneKByte array (unless any other statically
    // defined or shared regions have been declared elsewhere).
}
   </pre> </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 by <a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20 </li>
  </ul>
</div>
</body>
</html>