#include "portable.h"
#include "list.h"
Go to the source code of this file.
Data Structures | |
struct | xMEMORY_REGION |
struct | xTASK_PARAMTERS |
struct | xTIME_OUT |
Defines | |
#define | taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() |
#define | taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() |
#define | taskENTER_CRITICAL() portENTER_CRITICAL() |
#define | taskEXIT_CRITICAL() portEXIT_CRITICAL() |
#define | taskSCHEDULER_NOT_STARTED 0 |
#define | taskSCHEDULER_RUNNING 1 |
#define | taskSCHEDULER_SUSPENDED 2 |
#define | taskYIELD() portYIELD() |
#define | tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 ) |
#define | tskKERNEL_VERSION_NUMBER "V6.0.0" |
#define | xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) ) |
#define | xTaskCreateRestricted(x, pxCreatedTask) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) ) |
Typedefs | |
typedef struct xMEMORY_REGION | xMemoryRegion |
typedef void * | xTaskHandle |
typedef struct xTASK_PARAMTERS | xTaskParameters |
typedef struct xTIME_OUT | xTimeOutType |
Functions | |
unsigned long | ulTaskEndTrace (void) PRIVILEGED_FUNCTION |
unsigned portBASE_TYPE | uxTaskGetNumberOfTasks (void) PRIVILEGED_FUNCTION |
unsigned portBASE_TYPE | uxTaskGetStackHighWaterMark (xTaskHandle xTask) PRIVILEGED_FUNCTION |
task.h | |
unsigned portBASE_TYPE | uxTaskPriorityGet (xTaskHandle pxTask) PRIVILEGED_FUNCTION |
void | vTaskAllocateMPURegions (xTaskHandle xTask, const xMemoryRegion *const pxRegions) PRIVILEGED_FUNCTION |
void | vTaskCleanUpResources (void) PRIVILEGED_FUNCTION |
void | vTaskDelay (portTickType xTicksToDelay) PRIVILEGED_FUNCTION |
void | vTaskDelayUntil (portTickType *const pxPreviousWakeTime, portTickType xTimeIncrement) PRIVILEGED_FUNCTION |
void | vTaskDelete (xTaskHandle pxTask) PRIVILEGED_FUNCTION |
void | vTaskEndScheduler (void) PRIVILEGED_FUNCTION |
void | vTaskGetRunTimeStats (signed char *pcWriteBuffer) PRIVILEGED_FUNCTION |
void | vTaskIncrementTick (void) PRIVILEGED_FUNCTION |
void | vTaskList (signed char *pcWriteBuffer) PRIVILEGED_FUNCTION |
void | vTaskMissedYield (void) PRIVILEGED_FUNCTION |
void | vTaskPlaceOnEventList (const xList *const pxEventList, portTickType xTicksToWait) PRIVILEGED_FUNCTION |
void | vTaskPriorityDisinherit (xTaskHandle *const pxMutexHolder) PRIVILEGED_FUNCTION |
void | vTaskPriorityInherit (xTaskHandle *const pxMutexHolder) PRIVILEGED_FUNCTION |
void | vTaskPrioritySet (xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority) PRIVILEGED_FUNCTION |
void | vTaskResume (xTaskHandle pxTaskToResume) PRIVILEGED_FUNCTION |
void | vTaskSetApplicationTaskTag (xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction) PRIVILEGED_FUNCTION |
task.h | |
void | vTaskSetTimeOutState (xTimeOutType *const pxTimeOut) PRIVILEGED_FUNCTION |
void | vTaskStartScheduler (void) PRIVILEGED_FUNCTION |
void | vTaskStartTrace (signed char *pcBuffer, unsigned long ulBufferSize) PRIVILEGED_FUNCTION |
void | vTaskSuspend (xTaskHandle pxTaskToSuspend) PRIVILEGED_FUNCTION |
void | vTaskSuspendAll (void) PRIVILEGED_FUNCTION |
void | vTaskSwitchContext (void) PRIVILEGED_FUNCTION |
portBASE_TYPE | xTaskCallApplicationTaskHook (xTaskHandle xTask, void *pvParameter) PRIVILEGED_FUNCTION |
task.h | |
portBASE_TYPE | xTaskCheckForTimeOut (xTimeOutType *const pxTimeOut, portTickType *const pxTicksToWait) PRIVILEGED_FUNCTION |
signed portBASE_TYPE | xTaskGenericCreate (pdTASK_CODE pvTaskCode, const signed char *const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion *const xRegions) PRIVILEGED_FUNCTION |
pdTASK_HOOK_CODE | xTaskGetApplicationTaskTag (xTaskHandle xTask) PRIVILEGED_FUNCTION |
task.h | |
xTaskHandle | xTaskGetCurrentTaskHandle (void) PRIVILEGED_FUNCTION |
portBASE_TYPE | xTaskGetSchedulerState (void) PRIVILEGED_FUNCTION |
portTickType | xTaskGetTickCount (void) PRIVILEGED_FUNCTION |
signed portBASE_TYPE | xTaskIsTaskSuspended (xTaskHandle xTask) PRIVILEGED_FUNCTION |
task. | |
signed portBASE_TYPE | xTaskRemoveFromEventList (const xList *const pxEventList) PRIVILEGED_FUNCTION |
signed portBASE_TYPE | xTaskResumeAll (void) PRIVILEGED_FUNCTION |
portBASE_TYPE | xTaskResumeFromISR (xTaskHandle pxTaskToResume) PRIVILEGED_FUNCTION |
#define taskENTER_CRITICAL | ( | ) | portENTER_CRITICAL() |
Definition at line 151 of file task.h.
Referenced by prvIsQueueEmpty(), prvIsQueueFull(), prvUnlockQueue(), uxQueueMessagesWaiting(), xQueueGenericReceive(), and xQueueGenericSend().
#define taskEXIT_CRITICAL | ( | ) | portEXIT_CRITICAL() |
Definition at line 165 of file task.h.
Referenced by prvIsQueueEmpty(), prvIsQueueFull(), prvUnlockQueue(), uxQueueMessagesWaiting(), xQueueGenericReceive(), and xQueueGenericSend().
#define taskYIELD | ( | ) | portYIELD() |
Definition at line 137 of file task.h.
Referenced by portTASK_FUNCTION(), prv1stHigherPriorityNormallyFullTask(), prv2ndHigherPriorityNormallyFullTask(), prvDecrementSemaphoreCount(), prvHigherPriorityNormallyEmptyTask(), prvIncrementSemaphoreCount(), prvLowPriorityMutexTask(), prvRecursiveMutexPollingTask(), prvSendFrontAndBackTest(), and vPrimaryBlockTimeTestTask().
#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 ) |
Definition at line 127 of file task.h.
Referenced by main(), vErrorChecks(), vStartAltBlockingQueueTasks(), vStartBlockingQueueTasks(), vStartCountingSemaphoreTasks(), vStartDynamicPriorityTasks(), vStartSemaphoreTasks(), and vTaskStartScheduler().
#define xTaskCreate | ( | pvTaskCode, | |||
pcName, | |||||
usStackDepth, | |||||
pvParameters, | |||||
uxPriority, | |||||
pxCreatedTask | ) | xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) ) |
Definition at line 272 of file task.h.
Referenced by main(), portTASK_FUNCTION(), vAltStartComTestTasks(), vCreateAltBlockTimeTasks(), vCreateBlockTimeTasks(), vCreateSuicidalTasks(), vErrorChecks(), vStartAltBlockingQueueTasks(), vStartAltGenericQueueTasks(), vStartAltPolledQueueTasks(), vStartBlockingQueueTasks(), vStartCountingSemaphoreTasks(), vStartDynamicPriorityTasks(), vStartGenericQueueTasks(), vStartIntegerMathTasks(), vStartInterruptQueueTasks(), vStartLEDFlashTasks(), vStartMathTasks(), vStartPolledQueueTasks(), vStartQueuePeekTasks(), vStartRecursiveMutexTasks(), vStartSemaphoreTasks(), and vTaskStartScheduler().
#define xTaskCreateRestricted | ( | x, | |||
pxCreatedTask | ) | xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) ) |
typedef struct xMEMORY_REGION xMemoryRegion |
typedef void* xTaskHandle |
typedef struct xTASK_PARAMTERS xTaskParameters |
typedef struct xTIME_OUT xTimeOutType |
unsigned long ulTaskEndTrace | ( | void | ) |
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 }
unsigned portBASE_TYPE uxTaskGetStackHighWaterMark | ( | xTaskHandle | xTask | ) |
unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );
INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for this function to be available.
Returns the high water mark of the stack associated with xTask. That is, the minimum free stack space there has been (in bytes) since the task started. The smaller the returned number the closer the task has come to overflowing its stack.
xTask | Handle of the task associated with the stack to be checked. Set xTask to NULL to check the stack of the calling task. |
unsigned portBASE_TYPE uxTaskPriorityGet | ( | xTaskHandle | pxTask | ) |
Referenced by portTASK_FUNCTION(), and prvLowPriorityMutexTask().
void vTaskAllocateMPURegions | ( | xTaskHandle | xTask, | |
const xMemoryRegion *const | pxRegions | |||
) |
void vTaskCleanUpResources | ( | void | ) |
void vTaskDelay | ( | portTickType | xTicksToDelay | ) |
void vTaskDelayUntil | ( | portTickType *const | pxPreviousWakeTime, | |
portTickType | xTimeIncrement | |||
) |
Referenced by portTASK_FUNCTION().
void vTaskDelete | ( | xTaskHandle | pxTask | ) |
Referenced by portTASK_FUNCTION(), and vErrorChecks().
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 vTaskGetRunTimeStats | ( | signed char * | pcWriteBuffer | ) |
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 vTaskList | ( | signed char * | pcWriteBuffer | ) |
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 vTaskPriorityDisinherit | ( | xTaskHandle *const | pxMutexHolder | ) |
Referenced by prvCopyDataToQueue().
void vTaskPriorityInherit | ( | xTaskHandle *const | pxMutexHolder | ) |
Referenced by xQueueGenericReceive().
void vTaskPrioritySet | ( | xTaskHandle | pxTask, | |
unsigned portBASE_TYPE | uxNewPriority | |||
) |
void vTaskResume | ( | xTaskHandle | pxTaskToResume | ) |
Referenced by portTASK_FUNCTION(), prv1stHigherPriorityNormallyFullTask(), prvHigherPriorityNormallyEmptyTask(), prvLowerPriorityNormallyEmptyTask(), prvLowerPriorityNormallyFullTask(), prvLowPriorityMutexTask(), prvLowPriorityPeekTask(), prvRecursiveMutexPollingTask(), and vPrimaryBlockTimeTestTask().
void vTaskSetApplicationTaskTag | ( | xTaskHandle | xTask, | |
pdTASK_HOOK_CODE | pxHookFunction | |||
) |
void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );
Sets pxHookFunction to be the task hook function used by the task xTask. Passing xTask as NULL has the effect of setting the calling tasks hook function.
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 vTaskStartTrace | ( | signed char * | pcBuffer, | |
unsigned long | ulBufferSize | |||
) |
void vTaskSuspend | ( | xTaskHandle | pxTaskToSuspend | ) |
Referenced by portTASK_FUNCTION(), prv1stHigherPriorityNormallyFullTask(), prvHigherPriorityNormallyEmptyTask(), prvHighestPriorityPeekTask(), prvHighPriorityMutexTask(), prvHighPriorityPeekTask(), prvMediumPriorityMutexTask(), prvMediumPriorityPeekTask(), prvRecursiveMutexBlockingTask(), prvRecursiveMutexControllingTask(), and vSecondaryBlockTimeTestTask().
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 xTaskCallApplicationTaskHook | ( | xTaskHandle | xTask, | |
void * | pvParameter | |||
) |
portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );
Calls the hook function associated with xTask. Passing xTask as NULL has the effect of calling the Running tasks (the calling task) hook function.
pvParameter is passed to the hook function for the task to interpret as it wants.
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 }
signed portBASE_TYPE xTaskGenericCreate | ( | pdTASK_CODE | pvTaskCode, | |
const signed char *const | pcName, | |||
unsigned short | usStackDepth, | |||
void * | pvParameters, | |||
unsigned portBASE_TYPE | uxPriority, | |||
xTaskHandle * | pxCreatedTask, | |||
portSTACK_TYPE * | puxStackBuffer, | |||
const xMemoryRegion *const | xRegions | |||
) |
pdTASK_HOOK_CODE xTaskGetApplicationTaskTag | ( | xTaskHandle | xTask | ) |
void xTaskGetApplicationTaskTag( xTaskHandle xTask );
Returns the pxHookFunction value assigned to the task xTask.
xTaskHandle xTaskGetCurrentTaskHandle | ( | void | ) |
Referenced by xQueueGenericReceive().
portBASE_TYPE xTaskGetSchedulerState | ( | void | ) |
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 xTaskIsTaskSuspended | ( | xTaskHandle | xTask | ) |
task.
h
signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask );
Utility task that simply returns pdTRUE if the task referenced by xTask is currently in the Suspended state, or pdFALSE if the task referenced by xTask is in any other state.
Referenced by prvLowerPriorityNormallyEmptyTask(), and prvLowerPriorityNormallyFullTask().
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 }
portBASE_TYPE xTaskResumeFromISR | ( | xTaskHandle | pxTaskToResume | ) |