xTaskCreateRestricted
[FreeRTOS-MPU Specific]

task. h
portBASE_TYPE xTaskCreateRestricted( xTaskParameters *pxTaskDefinition, xTaskHandle *pxCreatedTask );

Create a new Memory Protection Unit (MPU) restricted task and add it to the list of tasks that are ready to run.

xTaskCreateRestricted() is intended for use with FreeRTOS-MPU, the demo applications for which contain comprehensive and documented examples of xTaskCreateRestricted() being used.

Parameters:
pxTaskDefinition Pointer to a structure that defines the task. The structure is described on this page.
pxCreatedTask Used to pass back a handle by which the created task can be referenced.
Returns:
pdPASS if the task was successfully created and added to a ready list, otherwise an error code defined in the file projdefs.h

Tasks that include MPU support require even more parameters to create than those that don't. Passing each parameter to xTaskCreateRestricted() individually would be unwieldy so instead the structure xTaskParameters is used to allow the parameters to be configured statically at compile time. The structure is defined in task.h as:



typedef struct xTASK_PARAMTERS
{
    pdTASK_CODE pvTaskCode;
    const signed char * const pcName;
    unsigned short usStackDepth;
    void *pvParameters;
    unsigned portBASE_TYPE uxPriority;
    portSTACK_TYPE *puxStackBuffer;
    xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];
} xTaskParameters;

....where xMemoryRegion is defined as:

typedef struct xMEMORY_REGION
{
    void *pvBaseAddress;
    unsigned long ulLengthInBytes;
    unsigned long ulParameters;
} xMemoryRegion;


Following is a description of each structure member:

Example usage (please refer to the FreeRTOS-MPU demo applications for a much more complete and comprehensive example):

/* Declare the stack that will be used by the task. The stack alignment must match its size and be a power of 2, so if 128 words are reserved for the stack then it must be aligned to ( 128 * 4 ) bytes. This example used GCC syntax. */ static portSTACK_TYPE xTaskStack[ 128 ] __attribute__((aligned(128*4))); /* Declare an array that will be accessed by the task. The task should only be able to read from the array, and not write to it. */ char cReadOnlyArray[ 512 ] __attribute__((aligned(512))); /* Fill in a xTaskParameters structure to define the task - this is the structure passed to the xTaskCreateRestricted() function. */ static const xTaskParameters xTaskDefinition = { vTaskFunction, /* pvTaskCode */ "A task", /* pcName */ 128, /* usStackDepth - defined in words, not bytes. */ NULL, /* pvParameters */ 1, /* uxPriority - priority 1, start in User mode. */ xTaskStack, /* puxStackBuffer - the array to use as the task stack. */ /* xRegions - In this case only one of the three user definable regions is actually used. The parameters are used to set the region to read only. */ { /* Base address Length Parameters */ { cReadOnlyArray, mainREAD_ONLY_ALIGN_SIZE, portMPU_REGION_READ_ONLY }, { 0, 0, 0 }, { 0, 0, 0 }, } }; void main( void ) { /* Create the task defined by xTaskDefinition. NULL is used as the second parameter as a task handle is not required. */ xTaskCreateRestricted( &xTaskDefinition, NULL ); /* Start the scheduler. */ vTaskStartScheduler(); /* Should not reach here! */ }





Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2012 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd..