tasks.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "StackMacros.h"

Go to the source code of this file.

Data Structures

struct  tskTaskControlBlock

Defines

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#define prvAddTaskToReadyQueue(pxTCB)
#define prvCheckDelayedTasks()
#define prvGetTCBFromHandle(pxHandle)   ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle )
#define tskBLOCKED_CHAR   ( ( signed char ) 'B' )
#define tskDELETED_CHAR   ( ( signed char ) 'D' )
#define tskIDLE_PRIORITY   ( ( unsigned portBASE_TYPE ) 0 )
#define tskIDLE_STACK_SIZE   configMINIMAL_STACK_SIZE
#define tskREADY_CHAR   ( ( signed char ) 'R' )
#define tskSTACK_FILL_BYTE   ( 0xa5 )
#define tskSUSPENDED_CHAR   ( ( signed char ) 'S' )
#define vWriteTraceToBuffer()

Typedefs

typedef struct tskTaskControlBlock tskTCB

Functions

static portTASK_FUNCTION (prvIdleTask, pvParameters)
static tskTCBprvAllocateTCBAndStack (unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer)
static void prvCheckTasksWaitingTermination (void)
static void prvInitialiseTaskLists (void)
static void prvInitialiseTaskLists (static void prvCheckTasksWaitingTermination void)
static void prvInitialiseTCBVariables (tskTCB *pxTCB, const signed char *const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion *const xRegions, unsigned short usStackDepth) PRIVILEGED_FUNCTION
unsigned portBASE_TYPE uxTaskGetNumberOfTasks (void)
void vTaskEndScheduler (void)
void vTaskIncrementTick (void)
void vTaskMissedYield (void)
void vTaskPlaceOnEventList (const xList *const pxEventList, portTickType xTicksToWait)
void vTaskSetTimeOutState (xTimeOutType *const pxTimeOut)
void vTaskStartScheduler (void)
void vTaskSuspendAll (void)
void vTaskSwitchContext (void)
portBASE_TYPE xTaskCheckForTimeOut (xTimeOutType *const pxTimeOut, portTickType *const pxTicksToWait)
portTickType xTaskGetTickCount (void)
signed portBASE_TYPE xTaskRemoveFromEventList (const xList *const pxEventList)
signed portBASE_TYPE xTaskResumeAll (void)

Variables

PRIVILEGED_DATA tskTCB *volatile pxCurrentTCB = NULL
static PRIVILEGED_DATA xList
*volatile 
pxDelayedTaskList
static PRIVILEGED_DATA xList
*volatile 
pxOverflowDelayedTaskList
static PRIVILEGED_DATA xList pxReadyTasksLists [configMAX_PRIORITIES]
static PRIVILEGED_DATA
volatile unsigned
portBASE_TYPE 
uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0
static PRIVILEGED_DATA
volatile unsigned
portBASE_TYPE 
uxMissedTicks = ( unsigned portBASE_TYPE ) 0
static PRIVILEGED_DATA
volatile unsigned
portBASE_TYPE 
uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE
static PRIVILEGED_DATA
unsigned portBASE_TYPE 
uxTaskNumber = ( unsigned portBASE_TYPE ) 0
static PRIVILEGED_DATA
volatile unsigned
portBASE_TYPE 
uxTopReadyPriority = tskIDLE_PRIORITY
static PRIVILEGED_DATA
unsigned portBASE_TYPE 
uxTopUsedPriority = tskIDLE_PRIORITY
static PRIVILEGED_DATA xList xDelayedTaskList1
static PRIVILEGED_DATA xList xDelayedTaskList2
static PRIVILEGED_DATA
volatile portBASE_TYPE 
xMissedYield = ( portBASE_TYPE ) pdFALSE
static PRIVILEGED_DATA
volatile portBASE_TYPE 
xNumOfOverflows = ( portBASE_TYPE ) 0
static PRIVILEGED_DATA xList xPendingReadyList
static PRIVILEGED_DATA
volatile signed portBASE_TYPE 
xSchedulerRunning = pdFALSE
static PRIVILEGED_DATA
volatile portTickType 
xTickCount = ( portTickType ) 0


Define Documentation

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE

Definition at line 62 of file tasks.c.

#define prvAddTaskToReadyQueue ( pxTCB   ) 

Value:

{                                                                                                               \
    if( pxTCB->uxPriority > uxTopReadyPriority )                                                                \
    {                                                                                                           \
        uxTopReadyPriority = pxTCB->uxPriority;                                                                 \
    }                                                                                                           \
    vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) );    \
}

Definition at line 252 of file tasks.c.

Referenced by prvInitialiseTaskLists(), xTaskRemoveFromEventList(), and xTaskResumeAll().

 
#define prvCheckDelayedTasks (  ) 

Value:

{                                                                                                                   \
register tskTCB *pxTCB;                                                                                             \
                                                                                                                    \
    while( ( pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ) ) != NULL )                      \
    {                                                                                                               \
        if( xTickCount < listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ) )                                  \
        {                                                                                                           \
            break;                                                                                                  \
        }                                                                                                           \
        vListRemove( &( pxTCB->xGenericListItem ) );                                                                \
        /* Is the task waiting on an event also? */                                                                 \
        if( pxTCB->xEventListItem.pvContainer )                                                                     \
        {                                                                                                           \
            vListRemove( &( pxTCB->xEventListItem ) );                                                              \
        }                                                                                                           \
        prvAddTaskToReadyQueue( pxTCB );                                                                            \
    }                                                                                                               \
}

Definition at line 270 of file tasks.c.

Referenced by vTaskIncrementTick().

#define prvGetTCBFromHandle ( pxHandle   )     ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle )

Definition at line 297 of file tasks.c.

#define tskBLOCKED_CHAR   ( ( signed char ) 'B' )

Definition at line 186 of file tasks.c.

#define tskDELETED_CHAR   ( ( signed char ) 'D' )

Definition at line 188 of file tasks.c.

#define tskIDLE_PRIORITY   ( ( unsigned portBASE_TYPE ) 0 )

Definition at line 75 of file tasks.c.

#define tskIDLE_STACK_SIZE   configMINIMAL_STACK_SIZE

Definition at line 73 of file tasks.c.

Referenced by vTaskStartScheduler().

#define tskREADY_CHAR   ( ( signed char ) 'R' )

Definition at line 187 of file tasks.c.

#define tskSTACK_FILL_BYTE   ( 0xa5 )

Definition at line 181 of file tasks.c.

Referenced by prvAllocateTCBAndStack().

#define tskSUSPENDED_CHAR   ( ( signed char ) 'S' )

Definition at line 189 of file tasks.c.

 
#define vWriteTraceToBuffer (  ) 

Definition at line 240 of file tasks.c.

Referenced by vTaskSwitchContext().


Typedef Documentation

typedef struct tskTaskControlBlock tskTCB


Function Documentation

static portTASK_FUNCTION ( prvIdleTask  ,
pvParameters   
) [static]

Definition at line 1780 of file tasks.c.

References listCURRENT_LIST_LENGTH, prvCheckTasksWaitingTermination(), pxReadyTasksLists, and taskYIELD.

01781 {
01782     /* Stop warnings. */
01783     ( void ) pvParameters;
01784 
01785     for( ;; )
01786     {
01787         /* See if any tasks have been deleted. */
01788         prvCheckTasksWaitingTermination();
01789 
01790         #if ( configUSE_PREEMPTION == 0 )
01791         {
01792             /* If we are not using preemption we keep forcing a task switch to
01793             see if any other task has become available.  If we are using
01794             preemption we don't need to do this as any task becoming available
01795             will automatically get the processor anyway. */
01796             taskYIELD();
01797         }
01798         #endif
01799 
01800         #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) )
01801         {
01802             /* When using preemption tasks of equal priority will be
01803             timesliced.  If a task that is sharing the idle priority is ready
01804             to run then the idle task should yield before the end of the
01805             timeslice.
01806 
01807             A critical region is not required here as we are just reading from
01808             the list, and an occasional incorrect value will not matter.  If
01809             the ready list at the idle priority contains more than one task
01810             then a task other than the idle task is ready to execute. */
01811             if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( unsigned portBASE_TYPE ) 1 )
01812             {
01813                 taskYIELD();
01814             }
01815         }
01816         #endif
01817 
01818         #if ( configUSE_IDLE_HOOK == 1 )
01819         {
01820             extern void vApplicationIdleHook( void );
01821 
01822             /* Call the user defined function from within the idle task.  This
01823             allows the application designer to add background functionality
01824             without the overhead of a separate task.
01825             NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
01826             CALL A FUNCTION THAT MIGHT BLOCK. */
01827             vApplicationIdleHook();
01828         }
01829         #endif
01830     }
01831 } /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */

static tskTCB* prvAllocateTCBAndStack ( unsigned short  usStackDepth,
portSTACK_TYPE *  puxStackBuffer 
) [static]

Definition at line 1998 of file tasks.c.

References portSTACK_TYPE, pvPortMalloc(), pvPortMallocAligned, tskTaskControlBlock::pxStack, tskSTACK_FILL_BYTE, and vPortFree().

Referenced by prvInitialiseTaskLists().

01999 {
02000 tskTCB *pxNewTCB;
02001 
02002     /* Allocate space for the TCB.  Where the memory comes from depends on
02003     the implementation of the port malloc function. */
02004     pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) );
02005 
02006     if( pxNewTCB != NULL )
02007     {
02008         /* Allocate space for the stack used by the task being created.
02009         The base of the stack memory stored in the TCB so the task can
02010         be deleted later if required. */
02011         pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t )usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer );
02012 
02013         if( pxNewTCB->pxStack == NULL )
02014         {
02015             /* Could not allocate the stack.  Delete the allocated TCB. */
02016             vPortFree( pxNewTCB );
02017             pxNewTCB = NULL;
02018         }
02019         else
02020         {
02021             /* Just to help debugging. */
02022             memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) );
02023         }
02024     }
02025 
02026     return pxNewTCB;
02027 }

static void prvCheckTasksWaitingTermination ( void   )  [static]

Definition at line 1963 of file tasks.c.

References listGET_OWNER_OF_HEAD_ENTRY, listLIST_IS_EMPTY, portENTER_CRITICAL, portEXIT_CRITICAL, uxCurrentNumberOfTasks, vListRemove(), vTaskSuspendAll(), tskTaskControlBlock::xGenericListItem, and xTaskResumeAll().

Referenced by portTASK_FUNCTION().

01964 {
01965     #if ( INCLUDE_vTaskDelete == 1 )
01966     {
01967         portBASE_TYPE xListIsEmpty;
01968 
01969         /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
01970         too often in the idle task. */
01971         if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0 )
01972         {
01973             vTaskSuspendAll();
01974                 xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
01975             xTaskResumeAll();
01976 
01977             if( !xListIsEmpty )
01978             {
01979                 tskTCB *pxTCB;
01980 
01981                 portENTER_CRITICAL();
01982                 {
01983                     pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) );
01984                     vListRemove( &( pxTCB->xGenericListItem ) );
01985                     --uxCurrentNumberOfTasks;
01986                     --uxTasksDeleted;
01987                 }
01988                 portEXIT_CRITICAL();
01989 
01990                 prvDeleteTCB( pxTCB );
01991             }
01992         }
01993     }
01994     #endif
01995 }

static void prvInitialiseTaskLists ( void   )  [static]

Definition at line 1931 of file tasks.c.

References configMAX_PRIORITIES, pxDelayedTaskList, pxReadyTasksLists, vListInitialise(), xDelayedTaskList1, xDelayedTaskList2, and xPendingReadyList.

01932 {
01933 unsigned portBASE_TYPE uxPriority;
01934 
01935     for( uxPriority = 0; uxPriority < configMAX_PRIORITIES; uxPriority++ )
01936     {
01937         vListInitialise( ( xList * ) &( pxReadyTasksLists[ uxPriority ] ) );
01938     }
01939 
01940     vListInitialise( ( xList * ) &xDelayedTaskList1 );
01941     vListInitialise( ( xList * ) &xDelayedTaskList2 );
01942     vListInitialise( ( xList * ) &xPendingReadyList );
01943 
01944     #if ( INCLUDE_vTaskDelete == 1 )
01945     {
01946         vListInitialise( ( xList * ) &xTasksWaitingTermination );
01947     }
01948     #endif
01949 
01950     #if ( INCLUDE_vTaskSuspend == 1 )
01951     {
01952         vListInitialise( ( xList * ) &xSuspendedTaskList );
01953     }
01954     #endif
01955 
01956     /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList
01957     using list2. */
01958     pxDelayedTaskList = &xDelayedTaskList1;
01959     pxOverflowDelayedTaskList = &xDelayedTaskList2;
01960 }

static void prvInitialiseTaskLists ( static void prvCheckTasksWaitingTermination  void  )  [static]

Definition at line 312 of file tasks.c.

References errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY, pdFALSE, pdPASS, pdTRUE, portBASE_TYPE, portENTER_CRITICAL, portEXIT_CRITICAL, portPRIVILEGE_BIT, portSTACK_TYPE, portYIELD_WITHIN_API, prvAddTaskToReadyQueue, prvAllocateTCBAndStack(), prvInitialiseTCBVariables(), pxCurrentTCB, pxPortInitialiseStack(), tskTaskControlBlock::pxStack, tskTaskControlBlock::pxTopOfStack, traceTASK_CREATE, traceTASK_CREATE_FAILED, uxCurrentNumberOfTasks, tskTaskControlBlock::uxPriority, uxTaskNumber, uxTopUsedPriority, and xSchedulerRunning.

00320                                                                       :
00321  *
00322  * void prvIdleTask( void *pvParameters );
00323  *
00324  */
00325 static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters );
00326 
00327 /*
00328  * Utility to free all memory allocated by the scheduler to hold a TCB,
00329  * including the stack pointed to by the TCB.
00330  *
00331  * This does not free memory allocated by the task itself (i.e. memory
00332  * allocated by calls to pvPortMalloc from within the tasks application code).
00333  */
00334 #if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) )
00335 
00336     static void prvDeleteTCB( tskTCB *pxTCB ) PRIVILEGED_FUNCTION;
00337 
00338 #endif
00339 
00340 /*
00341  * Used only by the idle task.  This checks to see if anything has been placed
00342  * in the list of tasks waiting to be deleted.  If so the task is cleaned up
00343  * and its TCB deleted.
00344  */
00345 static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION;
00346 
00347 /*
00348  * Allocates memory from the heap for a TCB and associated stack.  Checks the
00349  * allocation was successful.
00350  */
00351 static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) PRIVILEGED_FUNCTION;
00352 
00353 /*
00354  * Called from vTaskList.  vListTasks details all the tasks currently under
00355  * control of the scheduler.  The tasks may be in one of a number of lists.
00356  * prvListTaskWithinSingleList accepts a list and details the tasks from
00357  * within just that list.
00358  *
00359  * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM
00360  * NORMAL APPLICATION CODE.
00361  */
00362 #if ( configUSE_TRACE_FACILITY == 1 )
00363 
00364     static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus ) PRIVILEGED_FUNCTION;
00365 
00366 #endif
00367 
00368 /*
00369  * When a task is created, the stack of the task is filled with a known value.
00370  * This function determines the 'high water mark' of the task stack by
00371  * determining how much of the stack remains at the original preset value.
00372  */
00373 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
00374 
00375     static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) PRIVILEGED_FUNCTION;
00376 
00377 #endif
00378 
00379 
00380 /*lint +e956 */
00381 
00382 
00383 
00384 /*-----------------------------------------------------------
00385  * TASK CREATION API documented in task.h
00386  *----------------------------------------------------------*/
00387 
00388 signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions )
00389 {
00390 signed portBASE_TYPE xReturn;
00391 tskTCB * pxNewTCB;
00392 portBASE_TYPE xRunPrivileged;
00393 
00394     /* Allocate the memory required by the TCB and stack for the new task,
00395     checking that the allocation was successful. */
00396     pxNewTCB = prvAllocateTCBAndStack( usStackDepth, puxStackBuffer );
00397 
00398     if( pxNewTCB != NULL )
00399     {
00400         portSTACK_TYPE *pxTopOfStack;
00401 
00402         /* Should the task be created in privileged mode? */
00403         if( ( uxPriority & portPRIVILEGE_BIT ) != 0x00 )
00404         {
00405             xRunPrivileged = pdTRUE;
00406         }
00407         else
00408         {
00409             xRunPrivileged = pdFALSE;
00410         }
00411         uxPriority &= ~portPRIVILEGE_BIT;
00412 
00413         /* Calculate the top of stack address.  This depends on whether the
00414         stack grows from high memory to low (as per the 80x86) or visa versa.
00415         portSTACK_GROWTH is used to make the result positive or negative as
00416         required by the port. */
00417         #if( portSTACK_GROWTH < 0 )
00418         {
00419             pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );
00420             pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( unsigned long ) pxTopOfStack ) & ( ( unsigned long ) ~portBYTE_ALIGNMENT_MASK  ) );
00421         }
00422         #else
00423         {
00424             pxTopOfStack = pxNewTCB->pxStack;
00425 
00426             /* If we want to use stack checking on architectures that use
00427             a positive stack growth direction then we also need to store the
00428             other extreme of the stack space. */
00429             pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );
00430         }
00431         #endif
00432 
00433         /* Setup the newly allocated TCB with the initial state of the task. */
00434         prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth );
00435 
00436         /* Initialize the TCB stack to look as if the task was already running,
00437         but had been interrupted by the scheduler.  The return address is set
00438         to the start of the task function. Once the stack has been initialised
00439         the top of stack variable is updated. */
00440         #if( portUSING_MPU_WRAPPERS == 1 )
00441         {
00442             pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged );
00443         }
00444         #else
00445         {
00446             pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );
00447             ( void ) xRunPrivileged;
00448         }
00449         #endif
00450 
00451         /* We are going to manipulate the task queues to add this task to a
00452         ready list, so must make sure no interrupts occur. */
00453         portENTER_CRITICAL();
00454         {
00455             uxCurrentNumberOfTasks++;
00456             if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 )
00457             {
00458                 /* As this is the first task it must also be the current task. */
00459                 pxCurrentTCB =  pxNewTCB;
00460 
00461                 /* This is the first task to be created so do the preliminary
00462                 initialisation required.  We will not recover if this call
00463                 fails, but we will report the failure. */
00464                 prvInitialiseTaskLists();
00465             }
00466             else
00467             {
00468                 /* If the scheduler is not already running, make this task the
00469                 current task if it is the highest priority task to be created
00470                 so far. */
00471                 if( xSchedulerRunning == pdFALSE )
00472                 {
00473                     if( pxCurrentTCB->uxPriority <= uxPriority )
00474                     {
00475                         pxCurrentTCB = pxNewTCB;
00476                     }
00477                 }
00478             }
00479 
00480             /* Remember the top priority to make context switching faster.  Use
00481             the priority in pxNewTCB as this has been capped to a valid value. */
00482             if( pxNewTCB->uxPriority > uxTopUsedPriority )
00483             {
00484                 uxTopUsedPriority = pxNewTCB->uxPriority;
00485             }
00486 
00487             #if ( configUSE_TRACE_FACILITY == 1 )
00488             {
00489                 /* Add a counter into the TCB for tracing only. */
00490                 pxNewTCB->uxTCBNumber = uxTaskNumber;
00491             }
00492             #endif
00493             uxTaskNumber++;
00494 
00495             prvAddTaskToReadyQueue( pxNewTCB );
00496 
00497             xReturn = pdPASS;
00498             traceTASK_CREATE( pxNewTCB );
00499         }
00500         portEXIT_CRITICAL();
00501     }
00502     else
00503     {
00504         xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
00505         traceTASK_CREATE_FAILED( pxNewTCB );
00506     }
00507 
00508     if( xReturn == pdPASS )
00509     {
00510         if( ( void * ) pxCreatedTask != NULL )
00511         {
00512             /* Pass the TCB out - in an anonymous way.  The calling function/
00513             task can use this as a handle to delete the task later if
00514             required.*/
00515             *pxCreatedTask = ( xTaskHandle ) pxNewTCB;
00516         }
00517 
00518         if( xSchedulerRunning != pdFALSE )
00519         {
00520             /* If the created task is of a higher priority than the current task
00521             then it should run now. */
00522             if( pxCurrentTCB->uxPriority < uxPriority )
00523             {
00524                 portYIELD_WITHIN_API();
00525             }
00526         }
00527     }
00528 
00529     return xReturn;
00530 }

static void prvInitialiseTCBVariables ( tskTCB pxTCB,
const signed char *const   pcName,
unsigned portBASE_TYPE  uxPriority,
const xMemoryRegion *const   xRegions,
unsigned short  usStackDepth 
) [static]

Definition at line 1845 of file tasks.c.

References configMAX_PRIORITIES, configMAX_TASK_NAME_LEN, listSET_LIST_ITEM_OWNER, listSET_LIST_ITEM_VALUE, tskTaskControlBlock::pcTaskName, tskTaskControlBlock::pxStack, tskTaskControlBlock::uxPriority, vListInitialiseItem(), tskTaskControlBlock::xEventListItem, and tskTaskControlBlock::xGenericListItem.

Referenced by prvInitialiseTaskLists().

01846 {
01847     /* Store the function name in the TCB. */
01848     #if configMAX_TASK_NAME_LEN > 1
01849     {
01850         /* Don't bring strncpy into the build unnecessarily. */
01851         strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
01852     }
01853     #endif
01854     pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = '\0';
01855 
01856     /* This is used as an array index so must ensure it's not too large.  First
01857     remove the privilege bit if one is present. */
01858     if( uxPriority >= configMAX_PRIORITIES )
01859     {
01860         uxPriority = configMAX_PRIORITIES - 1;
01861     }
01862 
01863     pxTCB->uxPriority = uxPriority;
01864     #if ( configUSE_MUTEXES == 1 )
01865     {
01866         pxTCB->uxBasePriority = uxPriority;
01867     }
01868     #endif
01869 
01870     vListInitialiseItem( &( pxTCB->xGenericListItem ) );
01871     vListInitialiseItem( &( pxTCB->xEventListItem ) );
01872 
01873     /* Set the pxTCB as a link back from the xListItem.  This is so we can get
01874     back to the containing TCB from a generic item in a list. */
01875     listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB );
01876 
01877     /* Event lists are always in priority order. */
01878     listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority );
01879     listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB );
01880 
01881     #if ( portCRITICAL_NESTING_IN_TCB == 1 )
01882     {
01883         pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0;
01884     }
01885     #endif
01886 
01887     #if ( configUSE_APPLICATION_TASK_TAG == 1 )
01888     {
01889         pxTCB->pxTaskTag = NULL;
01890     }
01891     #endif
01892 
01893     #if ( configGENERATE_RUN_TIME_STATS == 1 )
01894     {
01895         pxTCB->ulRunTimeCounter = 0UL;
01896     }
01897     #endif
01898 
01899     #if ( portUSING_MPU_WRAPPERS == 1 )
01900     {
01901         vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth );
01902     }
01903     #else
01904     {
01905         ( void ) xRegions;
01906         ( void ) usStackDepth;
01907     }
01908     #endif
01909 }

unsigned portBASE_TYPE uxTaskGetNumberOfTasks ( void   ) 

Definition at line 1179 of file tasks.c.

References uxCurrentNumberOfTasks.

Referenced by vCreateSuicidalTasks(), and xIsCreateTaskStillRunning().

01180 {
01181     /* A critical section is not required because the variables are of type
01182     portBASE_TYPE. */
01183     return uxCurrentNumberOfTasks;
01184 }

void vTaskEndScheduler ( void   ) 

Definition at line 1063 of file tasks.c.

References portDISABLE_INTERRUPTS, vPortEndScheduler(), and xSchedulerRunning.

01064 {
01065     /* Stop the scheduler interrupts and call the portable scheduler end
01066     routine so the original ISRs can be restored if necessary.  The port
01067     layer must ensure interrupts enable bit is left in the correct state. */
01068     portDISABLE_INTERRUPTS();
01069     xSchedulerRunning = pdFALSE;
01070     vPortEndScheduler();
01071 }

void vTaskIncrementTick ( void   ) 

Definition at line 1357 of file tasks.c.

References prvCheckDelayedTasks, pxDelayedTaskList, traceTASK_INCREMENT_TICK, uxMissedTicks, uxSchedulerSuspended, vApplicationTickHook(), xNumOfOverflows, and xTickCount.

Referenced by vTick(), and xTaskResumeAll().

01358 {
01359     /* Called by the portable layer each time a tick interrupt occurs.
01360     Increments the tick then checks to see if the new tick value will cause any
01361     tasks to be unblocked. */
01362     if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
01363     {
01364         ++xTickCount;
01365         if( xTickCount == ( portTickType ) 0 )
01366         {
01367             xList *pxTemp;
01368 
01369             /* Tick count has overflowed so we need to swap the delay lists.
01370             If there are any items in pxDelayedTaskList here then there is
01371             an error! */
01372             pxTemp = pxDelayedTaskList;
01373             pxDelayedTaskList = pxOverflowDelayedTaskList;
01374             pxOverflowDelayedTaskList = pxTemp;
01375             xNumOfOverflows++;
01376         }
01377 
01378         /* See if this tick has made a timeout expire. */
01379         prvCheckDelayedTasks();
01380     }
01381     else
01382     {
01383         ++uxMissedTicks;
01384 
01385         /* The tick hook gets called at regular intervals, even if the
01386         scheduler is locked. */
01387         #if ( configUSE_TICK_HOOK == 1 )
01388         {
01389             extern void vApplicationTickHook( void );
01390 
01391             vApplicationTickHook();
01392         }
01393         #endif
01394     }
01395 
01396     #if ( configUSE_TICK_HOOK == 1 )
01397     {
01398         extern void vApplicationTickHook( void );
01399 
01400         /* Guard against the tick hook being called when the missed tick
01401         count is being unwound (when the scheduler is being unlocked. */
01402         if( uxMissedTicks == 0 )
01403         {
01404             vApplicationTickHook();
01405         }
01406     }
01407     #endif
01408 
01409     traceTASK_INCREMENT_TICK( xTickCount );
01410 }

void vTaskMissedYield ( void   ) 

Definition at line 1764 of file tasks.c.

References pdTRUE, and xMissedYield.

Referenced by prvUnlockQueue().

01765 {
01766     xMissedYield = pdTRUE;
01767 }

void vTaskPlaceOnEventList ( const xList *const   pxEventList,
portTickType  xTicksToWait 
)

Definition at line 1597 of file tasks.c.

References listSET_LIST_ITEM_VALUE, portMAX_DELAY, pxCurrentTCB, pxDelayedTaskList, vListInsert(), vListInsertEnd(), vListRemove(), tskTaskControlBlock::xEventListItem, tskTaskControlBlock::xGenericListItem, and xTickCount.

Referenced by xQueueGenericReceive(), and xQueueGenericSend().

01598 {
01599 portTickType xTimeToWake;
01600 
01601     /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE
01602     SCHEDULER SUSPENDED. */
01603 
01604     /* Place the event list item of the TCB in the appropriate event list.
01605     This is placed in the list in priority order so the highest priority task
01606     is the first to be woken by the event. */
01607     vListInsert( ( xList * ) pxEventList, ( xListItem * ) &( pxCurrentTCB->xEventListItem ) );
01608 
01609     /* We must remove ourselves from the ready list before adding ourselves
01610     to the blocked list as the same list item is used for both lists.  We have
01611     exclusive access to the ready lists as the scheduler is locked. */
01612     vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01613 
01614 
01615     #if ( INCLUDE_vTaskSuspend == 1 )
01616     {
01617         if( xTicksToWait == portMAX_DELAY )
01618         {
01619             /* Add ourselves to the suspended task list instead of a delayed task
01620             list to ensure we are not woken by a timing event.  We will block
01621             indefinitely. */
01622             vListInsertEnd( ( xList * ) &xSuspendedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01623         }
01624         else
01625         {
01626             /* Calculate the time at which the task should be woken if the event does
01627             not occur.  This may overflow but this doesn't matter. */
01628             xTimeToWake = xTickCount + xTicksToWait;
01629 
01630             listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );
01631 
01632             if( xTimeToWake < xTickCount )
01633             {
01634                 /* Wake time has overflowed.  Place this item in the overflow list. */
01635                 vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01636             }
01637             else
01638             {
01639                 /* The wake time has not overflowed, so we can use the current block list. */
01640                 vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01641             }
01642         }
01643     }
01644     #else
01645     {
01646             /* Calculate the time at which the task should be woken if the event does
01647             not occur.  This may overflow but this doesn't matter. */
01648             xTimeToWake = xTickCount + xTicksToWait;
01649 
01650             listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );
01651 
01652             if( xTimeToWake < xTickCount )
01653             {
01654                 /* Wake time has overflowed.  Place this item in the overflow list. */
01655                 vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01656             }
01657             else
01658             {
01659                 /* The wake time has not overflowed, so we can use the current block list. */
01660                 vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
01661             }
01662     }
01663     #endif
01664 }

void vTaskSetTimeOutState ( xTimeOutType *const   pxTimeOut  ) 

Definition at line 1714 of file tasks.c.

References xNumOfOverflows, xTIME_OUT::xOverflowCount, xTickCount, and xTIME_OUT::xTimeOnEntering.

Referenced by xQueueGenericReceive(), xQueueGenericSend(), and xTaskCheckForTimeOut().

01715 {
01716     pxTimeOut->xOverflowCount = xNumOfOverflows;
01717     pxTimeOut->xTimeOnEntering = xTickCount;
01718 }

void vTaskStartScheduler ( void   ) 

Definition at line 1021 of file tasks.c.

References pdPASS, pdTRUE, portCONFIGURE_TIMER_FOR_RUN_TIME_STATS, portDISABLE_INTERRUPTS, portPRIVILEGE_BIT, tskIDLE_PRIORITY, tskIDLE_STACK_SIZE, xPortStartScheduler(), xSchedulerRunning, xTaskCreate, and xTickCount.

Referenced by main().

01022 {
01023 portBASE_TYPE xReturn;
01024 
01025     /* Add the idle task at the lowest priority. */
01026     xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL );
01027 
01028     if( xReturn == pdPASS )
01029     {
01030         /* Interrupts are turned off here, to ensure a tick does not occur
01031         before or during the call to xPortStartScheduler().  The stacks of
01032         the created tasks contain a status word with interrupts switched on
01033         so interrupts will automatically get re-enabled when the first task
01034         starts to run.
01035 
01036         STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE
01037         DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */
01038         portDISABLE_INTERRUPTS();
01039 
01040         xSchedulerRunning = pdTRUE;
01041         xTickCount = ( portTickType ) 0;
01042 
01043         /* If configGENERATE_RUN_TIME_STATS is defined then the following
01044         macro must be defined to configure the timer/counter used to generate
01045         the run time counter time base. */
01046         portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();
01047 
01048         /* Setting up the timer tick is hardware specific and thus in the
01049         portable interface. */
01050         if( xPortStartScheduler() )
01051         {
01052             /* Should not reach here as if the scheduler is running the
01053             function will not return. */
01054         }
01055         else
01056         {
01057             /* Should only reach here if a task calls xTaskEndScheduler(). */
01058         }
01059     }
01060 }

void vTaskSuspendAll ( void   ) 

Definition at line 1074 of file tasks.c.

References uxSchedulerSuspended.

Referenced by __malloc_lock(), portTASK_FUNCTION(), prvCheckTasksWaitingTermination(), pvPortMalloc(), pvPortRealloc(), vMemCheckTask(), vParTestSetLED(), vParTestToggleLED(), vPortFree(), xQueueGenericReceive(), and xQueueGenericSend().

01075 {
01076     /* A critical section is not required as the variable is of type
01077     portBASE_TYPE. */
01078     ++uxSchedulerSuspended;
01079 }

void vTaskSwitchContext ( void   ) 

Definition at line 1553 of file tasks.c.

References listGET_OWNER_OF_NEXT_ENTRY, listLIST_IS_EMPTY, pdTRUE, pxCurrentTCB, pxReadyTasksLists, taskFIRST_CHECK_FOR_STACK_OVERFLOW, taskSECOND_CHECK_FOR_STACK_OVERFLOW, traceTASK_SWITCHED_IN, traceTASK_SWITCHED_OUT, uxSchedulerSuspended, uxTopReadyPriority, vWriteTraceToBuffer, and xMissedYield.

Referenced by SCALLYield().

01554 {
01555     if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE )
01556     {
01557         /* The scheduler is currently suspended - do not allow a context
01558         switch. */
01559         xMissedYield = pdTRUE;
01560         return;
01561     }
01562 
01563     traceTASK_SWITCHED_OUT();
01564 
01565     #if ( configGENERATE_RUN_TIME_STATS == 1 )
01566     {
01567         unsigned long ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE();
01568 
01569             /* Add the amount of time the task has been running to the accumulated
01570             time so far.  The time the task started running was stored in
01571             ulTaskSwitchedInTime.  Note that there is no overflow protection here
01572             so count values are only valid until the timer overflows.  Generally
01573             this will be about 1 hour assuming a 1uS timer increment. */
01574             pxCurrentTCB->ulRunTimeCounter += ( ulTempCounter - ulTaskSwitchedInTime );
01575             ulTaskSwitchedInTime = ulTempCounter;
01576     }
01577     #endif
01578 
01579     taskFIRST_CHECK_FOR_STACK_OVERFLOW();
01580     taskSECOND_CHECK_FOR_STACK_OVERFLOW();
01581 
01582     /* Find the highest priority queue that contains ready tasks. */
01583     while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )
01584     {
01585         --uxTopReadyPriority;
01586     }
01587 
01588     /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the
01589     same priority get an equal share of the processor time. */
01590     listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );
01591 
01592     traceTASK_SWITCHED_IN();
01593     vWriteTraceToBuffer();
01594 }

portBASE_TYPE xTaskCheckForTimeOut ( xTimeOutType *const   pxTimeOut,
portTickType *const   pxTicksToWait 
)

Definition at line 1721 of file tasks.c.

References pdTRUE, portENTER_CRITICAL, portEXIT_CRITICAL, portMAX_DELAY, vTaskSetTimeOutState(), xNumOfOverflows, xTIME_OUT::xOverflowCount, xTickCount, and xTIME_OUT::xTimeOnEntering.

Referenced by xQueueGenericReceive(), and xQueueGenericSend().

01722 {
01723 portBASE_TYPE xReturn;
01724 
01725     portENTER_CRITICAL();
01726     {
01727         #if ( INCLUDE_vTaskSuspend == 1 )
01728             /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is
01729             the maximum block time then the task should block indefinitely, and
01730             therefore never time out. */
01731             if( *pxTicksToWait == portMAX_DELAY )
01732             {
01733                 xReturn = pdFALSE;
01734             }
01735             else /* We are not blocking indefinitely, perform the checks below. */
01736         #endif
01737 
01738         if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( ( portTickType ) xTickCount >= ( portTickType ) pxTimeOut->xTimeOnEntering ) )
01739         {
01740             /* The tick count is greater than the time at which vTaskSetTimeout()
01741             was called, but has also overflowed since vTaskSetTimeOut() was called.
01742             It must have wrapped all the way around and gone past us again. This
01743             passed since vTaskSetTimeout() was called. */
01744             xReturn = pdTRUE;
01745         }
01746         else if( ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering ) < ( portTickType ) *pxTicksToWait )
01747         {
01748             /* Not a genuine timeout. Adjust parameters for time remaining. */
01749             *pxTicksToWait -= ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering );
01750             vTaskSetTimeOutState( pxTimeOut );
01751             xReturn = pdFALSE;
01752         }
01753         else
01754         {
01755             xReturn = pdTRUE;
01756         }
01757     }
01758     portEXIT_CRITICAL();
01759 
01760     return xReturn;
01761 }

portTickType xTaskGetTickCount ( void   ) 

Definition at line 1164 of file tasks.c.

References portENTER_CRITICAL, portEXIT_CRITICAL, and xTickCount.

Referenced by portTASK_FUNCTION(), prvCheckDelayedList(), vPrimaryBlockTimeTestTask(), and vSecondaryBlockTimeTestTask().

01165 {
01166 portTickType xTicks;
01167 
01168     /* Critical section required if running on a 16 bit processor. */
01169     portENTER_CRITICAL();
01170     {
01171         xTicks = xTickCount;
01172     }
01173     portEXIT_CRITICAL();
01174 
01175     return xTicks;
01176 }

signed portBASE_TYPE xTaskRemoveFromEventList ( const xList *const   pxEventList  ) 

Definition at line 1667 of file tasks.c.

References listGET_OWNER_OF_HEAD_ENTRY, pdTRUE, prvAddTaskToReadyQueue, pxCurrentTCB, tskTaskControlBlock::uxPriority, uxSchedulerSuspended, vListInsertEnd(), vListRemove(), tskTaskControlBlock::xEventListItem, tskTaskControlBlock::xGenericListItem, and xPendingReadyList.

Referenced by prvUnlockQueue(), xQueueGenericReceive(), xQueueGenericSend(), xQueueGenericSendFromISR(), and xQueueReceiveFromISR().

01668 {
01669 tskTCB *pxUnblockedTCB;
01670 portBASE_TYPE xReturn;
01671 
01672     /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE
01673     SCHEDULER SUSPENDED.  It can also be called from within an ISR. */
01674 
01675     /* The event list is sorted in priority order, so we can remove the
01676     first in the list, remove the TCB from the delayed list, and add
01677     it to the ready list.
01678 
01679     If an event is for a queue that is locked then this function will never
01680     get called - the lock count on the queue will get modified instead.  This
01681     means we can always expect exclusive access to the event list here. */
01682     pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
01683     vListRemove( &( pxUnblockedTCB->xEventListItem ) );
01684 
01685     if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
01686     {
01687         vListRemove( &( pxUnblockedTCB->xGenericListItem ) );
01688         prvAddTaskToReadyQueue( pxUnblockedTCB );
01689     }
01690     else
01691     {
01692         /* We cannot access the delayed or ready lists, so will hold this
01693         task pending until the scheduler is resumed. */
01694         vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) );
01695     }
01696 
01697     if( pxUnblockedTCB->uxPriority >= pxCurrentTCB->uxPriority )
01698     {
01699         /* Return true if the task removed from the event list has
01700         a higher priority than the calling task.  This allows
01701         the calling task to know if it should force a context
01702         switch now. */
01703         xReturn = pdTRUE;
01704     }
01705     else
01706     {
01707         xReturn = pdFALSE;
01708     }
01709 
01710     return xReturn;
01711 }

signed portBASE_TYPE xTaskResumeAll ( void   ) 

Definition at line 1082 of file tasks.c.

References listGET_OWNER_OF_HEAD_ENTRY, pdTRUE, portENTER_CRITICAL, portEXIT_CRITICAL, portYIELD_WITHIN_API, prvAddTaskToReadyQueue, pxCurrentTCB, uxCurrentNumberOfTasks, uxMissedTicks, tskTaskControlBlock::uxPriority, uxSchedulerSuspended, vListRemove(), vTaskIncrementTick(), tskTaskControlBlock::xEventListItem, tskTaskControlBlock::xGenericListItem, xMissedYield, and xPendingReadyList.

Referenced by __malloc_unlock(), portTASK_FUNCTION(), prvCheckTasksWaitingTermination(), pvPortMalloc(), pvPortRealloc(), vMemCheckTask(), vParTestSetLED(), vParTestToggleLED(), vPortFree(), xQueueGenericReceive(), and xQueueGenericSend().

01083 {
01084 register tskTCB *pxTCB;
01085 signed portBASE_TYPE xAlreadyYielded = pdFALSE;
01086 
01087     /* It is possible that an ISR caused a task to be removed from an event
01088     list while the scheduler was suspended.  If this was the case then the
01089     removed task will have been added to the xPendingReadyList.  Once the
01090     scheduler has been resumed it is safe to move all the pending ready
01091     tasks from this list into their appropriate ready list. */
01092     portENTER_CRITICAL();
01093     {
01094         --uxSchedulerSuspended;
01095 
01096         if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
01097         {
01098             if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0 )
01099             {
01100                 portBASE_TYPE xYieldRequired = pdFALSE;
01101 
01102                 /* Move any readied tasks from the pending list into the
01103                 appropriate ready list. */
01104                 while( ( pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY(  ( ( xList * ) &xPendingReadyList ) ) ) != NULL )
01105                 {
01106                     vListRemove( &( pxTCB->xEventListItem ) );
01107                     vListRemove( &( pxTCB->xGenericListItem ) );
01108                     prvAddTaskToReadyQueue( pxTCB );
01109 
01110                     /* If we have moved a task that has a priority higher than
01111                     the current task then we should yield. */
01112                     if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
01113                     {
01114                         xYieldRequired = pdTRUE;
01115                     }
01116                 }
01117 
01118                 /* If any ticks occurred while the scheduler was suspended then
01119                 they should be processed now.  This ensures the tick count does not
01120                 slip, and that any delayed tasks are resumed at the correct time. */
01121                 if( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 )
01122                 {
01123                     while( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 )
01124                     {
01125                         vTaskIncrementTick();
01126                         --uxMissedTicks;
01127                     }
01128 
01129                     /* As we have processed some ticks it is appropriate to yield
01130                     to ensure the highest priority task that is ready to run is
01131                     the task actually running. */
01132                     #if configUSE_PREEMPTION == 1
01133                     {
01134                         xYieldRequired = pdTRUE;
01135                     }
01136                     #endif
01137                 }
01138 
01139                 if( ( xYieldRequired == pdTRUE ) || ( xMissedYield == pdTRUE ) )
01140                 {
01141                     xAlreadyYielded = pdTRUE;
01142                     xMissedYield = pdFALSE;
01143                     portYIELD_WITHIN_API();
01144                 }
01145             }
01146         }
01147     }
01148     portEXIT_CRITICAL();
01149 
01150     return xAlreadyYielded;
01151 }


Variable Documentation

PRIVILEGED_DATA tskTCB* volatile pxCurrentTCB = NULL

PRIVILEGED_DATA xList* volatile pxDelayedTaskList [static]

Definition at line 138 of file tasks.c.

Referenced by prvInitialiseTaskLists(), vTaskIncrementTick(), and vTaskPlaceOnEventList().

PRIVILEGED_DATA xList* volatile pxOverflowDelayedTaskList [static]

Definition at line 139 of file tasks.c.

PRIVILEGED_DATA xList pxReadyTasksLists[configMAX_PRIORITIES] [static]

Definition at line 135 of file tasks.c.

Referenced by portTASK_FUNCTION(), prvInitialiseTaskLists(), and vTaskSwitchContext().

PRIVILEGED_DATA volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0 [static]

PRIVILEGED_DATA volatile unsigned portBASE_TYPE uxMissedTicks = ( unsigned portBASE_TYPE ) 0 [static]

Definition at line 162 of file tasks.c.

Referenced by vTaskIncrementTick(), and xTaskResumeAll().

PRIVILEGED_DATA volatile unsigned portBASE_TYPE uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE [static]

PRIVILEGED_DATA unsigned portBASE_TYPE uxTaskNumber = ( unsigned portBASE_TYPE ) 0 [static]

Definition at line 165 of file tasks.c.

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA volatile unsigned portBASE_TYPE uxTopReadyPriority = tskIDLE_PRIORITY [static]

Definition at line 159 of file tasks.c.

Referenced by vTaskSwitchContext().

PRIVILEGED_DATA unsigned portBASE_TYPE uxTopUsedPriority = tskIDLE_PRIORITY [static]

Definition at line 158 of file tasks.c.

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA xList xDelayedTaskList1 [static]

Definition at line 136 of file tasks.c.

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA xList xDelayedTaskList2 [static]

Definition at line 137 of file tasks.c.

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA volatile portBASE_TYPE xMissedYield = ( portBASE_TYPE ) pdFALSE [static]

Definition at line 163 of file tasks.c.

Referenced by vTaskMissedYield(), vTaskSwitchContext(), and xTaskResumeAll().

PRIVILEGED_DATA volatile portBASE_TYPE xNumOfOverflows = ( portBASE_TYPE ) 0 [static]

Definition at line 164 of file tasks.c.

Referenced by vTaskIncrementTick(), vTaskSetTimeOutState(), and xTaskCheckForTimeOut().

PRIVILEGED_DATA xList xPendingReadyList [static]

Definition at line 140 of file tasks.c.

Referenced by prvInitialiseTaskLists(), xTaskRemoveFromEventList(), and xTaskResumeAll().

PRIVILEGED_DATA volatile signed portBASE_TYPE xSchedulerRunning = pdFALSE [static]

Definition at line 160 of file tasks.c.

Referenced by prvInitialiseTaskLists(), vTaskEndScheduler(), and vTaskStartScheduler().

PRIVILEGED_DATA volatile portTickType xTickCount = ( portTickType ) 0 [static]


Generated on Thu Dec 17 20:02:02 2009 for AVR32 UC3 - FreeRTOS Real Time Kernel by  doxygen 1.5.5