Microchip® Advanced Software Framework

tasks.c File Reference
#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "stack_macros.h"

Data Structures

struct  tskTaskControlBlock
 

Macros

#define configIDLE_TASK_NAME   "IDLE"
 
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
 
#define portRESET_READY_PRIORITY(uxPriority, uxTopReadyPriority)
 
#define prvAddTaskToReadyList(pxTCB)
 
#define prvGetTCBFromHandle(pxHandle)   ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) )
 
#define taskEVENT_LIST_ITEM_VALUE_IN_USE   0x80000000UL
 
#define taskNOT_WAITING_NOTIFICATION   ( ( uint8_t ) 0 )
 
#define taskNOTIFICATION_RECEIVED   ( ( uint8_t ) 2 )
 
#define taskRECORD_READY_PRIORITY(uxPriority)
 
#define taskRESET_READY_PRIORITY(uxPriority)
 
#define taskSELECT_HIGHEST_PRIORITY_TASK()
 
#define taskSWITCH_DELAYED_LISTS()
 
#define taskWAITING_NOTIFICATION   ( ( uint8_t ) 1 )
 
#define taskYIELD_IF_USING_PREEMPTION()   portYIELD_WITHIN_API()
 
#define tskBLOCKED_CHAR   ( 'B' )
 
#define tskDELETED_CHAR   ( 'D' )
 
#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 0 )
 
#define tskREADY_CHAR   ( 'R' )
 
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE   0
 
#define tskSTACK_FILL_BYTE   ( 0xa5U )
 
#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE   ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
 
#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 2 )
 
#define tskSTATICALLY_ALLOCATED_STACK_ONLY   ( ( uint8_t ) 1 )
 
#define tskSUSPENDED_CHAR   ( 'S' )
 

Typedefs

typedef tskTCB TCB_t
 
typedef struct tskTaskControlBlock tskTCB
 

Functions

char * pcTaskGetName (TaskHandle_t xTaskToQuery)
 
static portTASK_FUNCTION (prvIdleTask, pvParameters)
 
static void prvAddCurrentTaskToDelayedList (TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely)
 
static void prvAddNewTaskToReadyList (TCB_t *pxNewTCB)
 
static void prvCheckTasksWaitingTermination (void)
 
static void prvDeleteTCB (TCB_t *pxTCB)
 
static void prvInitialiseNewTask (TaskFunction_t pxTaskCode, const char *const pcName, const uint32_t ulStackDepth, void *const pvParameters, UBaseType_t uxPriority, TaskHandle_t *const pxCreatedTask, TCB_t *pxNewTCB, const MemoryRegion_t *const xRegions)
 
static void prvInitialiseTaskLists (static void prvCheckTasksWaitingTermination void)
 
static void prvInitialiseTaskLists (void)
 
static void prvResetNextTaskUnblockTime (void)
 
static BaseType_t prvTaskIsTaskSuspended (const TaskHandle_t xTask) PRIVILEGED_FUNCTION
 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. More...
 
void * pvTaskIncrementMutexHeldCount (void)
 
uint32_t ulTaskNotifyTake (BaseType_t xClearCountOnExit, TickType_t xTicksToWait)
 
UBaseType_t uxTaskGetNumberOfTasks (void)
 
UBaseType_t uxTaskPriorityGet (TaskHandle_t xTask)
 
UBaseType_t uxTaskPriorityGetFromISR (TaskHandle_t xTask)
 task. More...
 
TickType_t uxTaskResetEventItemValue (void)
 
void vTaskDelay (const TickType_t xTicksToDelay)
 
void vTaskDelayUntil (TickType_t *const pxPreviousWakeTime, const TickType_t xTimeIncrement)
 
void vTaskDelete (TaskHandle_t xTaskToDelete)
 
void vTaskEndScheduler (void)
 
void vTaskInternalSetTimeOutState (TimeOut_t *const pxTimeOut)
 
void vTaskMissedYield (void)
 
void vTaskNotifyGiveFromISR (TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken)
 
void vTaskPlaceOnEventList (List_t *const pxEventList, const TickType_t xTicksToWait)
 
void vTaskPlaceOnUnorderedEventList (List_t *pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait)
 
void vTaskPriorityDisinheritAfterTimeout (TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask)
 
void vTaskPrioritySet (TaskHandle_t xTask, UBaseType_t uxNewPriority)
 
void vTaskRemoveFromUnorderedEventList (ListItem_t *pxEventListItem, const TickType_t xItemValue)
 
void vTaskResume (TaskHandle_t xTaskToResume)
 
void vTaskSetTimeOutState (TimeOut_t *const pxTimeOut)
 
void vTaskStartScheduler (void)
 
void vTaskSuspend (TaskHandle_t xTaskToSuspend)
 
void vTaskSuspendAll (void)
 
void vTaskSwitchContext (void)
 
BaseType_t xTaskCheckForTimeOut (TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait)
 
BaseType_t xTaskGenericNotify (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue)
 
BaseType_t xTaskGenericNotifyFromISR (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken)
 
TaskHandle_t xTaskGetCurrentTaskHandle (void)
 
BaseType_t xTaskGetSchedulerState (void)
 
TickType_t xTaskGetTickCount (void)
 
TickType_t xTaskGetTickCountFromISR (void)
 
BaseType_t xTaskIncrementTick (void)
 
BaseType_t xTaskNotifyStateClear (TaskHandle_t xTask)
 
BaseType_t xTaskNotifyWait (uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait)
 
BaseType_t xTaskPriorityDisinherit (TaskHandle_t const pxMutexHolder)
 
BaseType_t xTaskPriorityInherit (TaskHandle_t const pxMutexHolder)
 
BaseType_t xTaskRemoveFromEventList (const List_t *const pxEventList)
 
BaseType_t xTaskResumeAll (void)
 
BaseType_t xTaskResumeFromISR (TaskHandle_t xTaskToResume)
 

Variables

PRIVILEGED_DATA TCB_t *volatile pxCurrentTCB = NULL
 
static PRIVILEGED_DATA List_t
*volatile 
pxDelayedTaskList
 
static PRIVILEGED_DATA List_t
*volatile 
pxOverflowDelayedTaskList
 
static PRIVILEGED_DATA List_t pxReadyTasksLists [configMAX_PRIORITIES]
 
static PRIVILEGED_DATA
volatile UBaseType_t 
uxCurrentNumberOfTasks = ( UBaseType_t ) 0U
 
static PRIVILEGED_DATA
volatile UBaseType_t 
uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U
 
static PRIVILEGED_DATA
volatile UBaseType_t 
uxPendedTicks = ( UBaseType_t ) 0U
 
static PRIVILEGED_DATA
volatile UBaseType_t 
uxSchedulerSuspended = ( UBaseType_t ) pdFALSE
 
static PRIVILEGED_DATA UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U
 
static PRIVILEGED_DATA
volatile UBaseType_t 
uxTopReadyPriority = tskIDLE_PRIORITY
 
static PRIVILEGED_DATA List_t xDelayedTaskList1
 
static PRIVILEGED_DATA List_t xDelayedTaskList2
 
static PRIVILEGED_DATA TaskHandle_t xIdleTaskHandle = NULL
 
static PRIVILEGED_DATA
volatile TickType_t 
xNextTaskUnblockTime = ( TickType_t ) 0U
 
static PRIVILEGED_DATA
volatile BaseType_t 
xNumOfOverflows = ( BaseType_t ) 0
 
static PRIVILEGED_DATA List_t xPendingReadyList
 
static PRIVILEGED_DATA
volatile BaseType_t 
xSchedulerRunning = pdFALSE
 
static PRIVILEGED_DATA List_t xSuspendedTaskList
 
static PRIVILEGED_DATA List_t xTasksWaitingTermination
 
static PRIVILEGED_DATA
volatile TickType_t 
xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT
 
static PRIVILEGED_DATA
volatile BaseType_t 
xYieldPending = pdFALSE
 

#define configIDLE_TASK_NAME   "IDLE"

Referenced by vTaskStartScheduler().

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#define portRESET_READY_PRIORITY (   uxPriority,
  uxTopReadyPriority 
)
#define prvAddTaskToReadyList (   pxTCB)
Value:
taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
static PRIVILEGED_DATA List_t pxReadyTasksLists[configMAX_PRIORITIES]
Definition: tasks.c:351
#define traceMOVED_TASK_TO_READY_STATE(pxTCB)
Definition: FreeRTOS.h:389
#define taskRECORD_READY_PRIORITY(uxPriority)
Definition: tasks.c:140
#define tracePOST_MOVED_TASK_TO_READY_STATE(pxTCB)
Definition: FreeRTOS.h:393
void vListInsertEnd(List_t *const pxList, ListItem_t *const pxNewListItem)
Definition: list.c:75

Referenced by prvAddNewTaskToReadyList(), vTaskNotifyGiveFromISR(), vTaskPriorityDisinheritAfterTimeout(), vTaskPrioritySet(), vTaskRemoveFromUnorderedEventList(), vTaskResume(), xTaskGenericNotify(), xTaskGenericNotifyFromISR(), xTaskIncrementTick(), xTaskPriorityDisinherit(), xTaskPriorityInherit(), xTaskRemoveFromEventList(), xTaskResumeAll(), and xTaskResumeFromISR().

#define prvGetTCBFromHandle (   pxHandle)    ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) )
#define taskNOT_WAITING_NOTIFICATION   ( ( uint8_t ) 0 )
#define taskNOTIFICATION_RECEIVED   ( ( uint8_t ) 2 )
#define taskRECORD_READY_PRIORITY (   uxPriority)
Value:
{ \
if( ( uxPriority ) > uxTopReadyPriority ) \
{ \
uxTopReadyPriority = ( uxPriority ); \
} \
} /* taskRECORD_READY_PRIORITY */
static PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority
Definition: tasks.c:374
#define taskRESET_READY_PRIORITY (   uxPriority)
#define taskSELECT_HIGHEST_PRIORITY_TASK ( )
Value:
{ \
UBaseType_t uxTopPriority = uxTopReadyPriority; \
\
/* Find the highest priority queue that contains ready tasks. */ \
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopPriority ] ) ) ) \
{ \
configASSERT( uxTopPriority ); \
--uxTopPriority; \
} \
\
/* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of \
the same priority get an equal share of the processor time. */ \
uxTopReadyPriority = uxTopPriority; \
} /* taskSELECT_HIGHEST_PRIORITY_TASK */
static PRIVILEGED_DATA List_t pxReadyTasksLists[configMAX_PRIORITIES]
Definition: tasks.c:351
#define listGET_OWNER_OF_NEXT_ENTRY(pxTCB, pxList)
Definition: list.h:277
PRIVILEGED_DATA TCB_t *volatile pxCurrentTCB
Definition: tasks.c:348
#define configASSERT(x)
Definition: FreeRTOSConfig.h:103
#define listLIST_IS_EMPTY(pxList)
Definition: list.h:250
static PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority
Definition: tasks.c:374

Referenced by vTaskSwitchContext().

#define taskSWITCH_DELAYED_LISTS ( )
Value:
{ \
List_t *pxTemp; \
\
/* The delayed tasks list should be empty when the lists are switched. */ \
\
pxTemp = pxDelayedTaskList; \
}
static PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows
Definition: tasks.c:378
static void prvResetNextTaskUnblockTime(void)
Definition: tasks.c:3730
#define configASSERT(x)
Definition: FreeRTOSConfig.h:103
#define listLIST_IS_EMPTY(pxList)
Definition: list.h:250
static PRIVILEGED_DATA List_t *volatile pxDelayedTaskList
Definition: tasks.c:354
struct xLIST List_t
static PRIVILEGED_DATA List_t *volatile pxOverflowDelayedTaskList
Definition: tasks.c:355

Referenced by xTaskIncrementTick().

#define taskWAITING_NOTIFICATION   ( ( uint8_t ) 1 )
#define taskYIELD_IF_USING_PREEMPTION ( )    portYIELD_WITHIN_API()
#define tskBLOCKED_CHAR   ( 'B' )
#define tskDELETED_CHAR   ( 'D' )
#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 0 )

Referenced by prvDeleteTCB().

#define tskREADY_CHAR   ( 'R' )
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE   0
#define tskSTACK_FILL_BYTE   ( 0xa5U )

Referenced by prvInitialiseNewTask().

#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE   ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 2 )

Referenced by prvDeleteTCB().

#define tskSTATICALLY_ALLOCATED_STACK_ONLY   ( ( uint8_t ) 1 )

Referenced by prvDeleteTCB().

#define tskSUSPENDED_CHAR   ( 'S' )

typedef tskTCB TCB_t
typedef struct tskTaskControlBlock tskTCB

char* pcTaskGetName ( TaskHandle_t  xTaskToQuery)
static void prvCheckTasksWaitingTermination ( void  )
static
static void prvInitialiseTaskLists ( static void prvCheckTasksWaitingTermination  void)
static
static BaseType_t prvTaskIsTaskSuspended ( const TaskHandle_t  xTask)
static

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.

References configASSERT, listIS_CONTAINED_WITHIN, mtCOVERAGE_TEST_MARKER, pdFALSE, pdTRUE, tskTaskControlBlock::xEventListItem, xPendingReadyList, tskTaskControlBlock::xStateListItem, and xSuspendedTaskList.

Referenced by vTaskResume(), and xTaskResumeFromISR().

void* pvTaskIncrementMutexHeldCount ( void  )
UBaseType_t uxTaskGetNumberOfTasks ( void  )
UBaseType_t uxTaskPriorityGet ( TaskHandle_t  xTask)
void vTaskDelayUntil ( TickType_t *const  pxPreviousWakeTime,
const TickType_t  xTimeIncrement 
)
void vTaskEndScheduler ( void  )
void vTaskMissedYield ( void  )

References pdTRUE, and xYieldPending.

Referenced by prvUnlockQueue().

void vTaskPlaceOnEventList ( List_t *const  pxEventList,
const TickType_t  xTicksToWait 
)
void vTaskPlaceOnUnorderedEventList ( List_t pxEventList,
const TickType_t  xItemValue,
const TickType_t  xTicksToWait 
)
TaskHandle_t xTaskGetCurrentTaskHandle ( void  )
TickType_t xTaskGetTickCount ( void  )

PRIVILEGED_DATA List_t* volatile pxOverflowDelayedTaskList
static
PRIVILEGED_DATA volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U
static
PRIVILEGED_DATA volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U
static
PRIVILEGED_DATA volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U
static
PRIVILEGED_DATA UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U
static
PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY
static
PRIVILEGED_DATA List_t xDelayedTaskList1
static

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA List_t xDelayedTaskList2
static

Referenced by prvInitialiseTaskLists().

PRIVILEGED_DATA TaskHandle_t xIdleTaskHandle = NULL
static

Referenced by vTaskStartScheduler().

PRIVILEGED_DATA volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U
static
PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0
static