firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
tasks.c File Reference
#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "stack_macros.h"
Include dependency graph for tasks.c:

Data Structures

struct  tskTaskControlBlock

Macros

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#define taskYIELD_TASK_CORE_IF_USING_PREEMPTION(pxTCB)
#define taskYIELD_ANY_CORE_IF_USING_PREEMPTION(pxTCB)
#define taskNOT_WAITING_NOTIFICATION   ( ( uint8_t ) 0 ) /* Must be zero as it is the initialised value. */
#define taskWAITING_NOTIFICATION   ( ( uint8_t ) 1 )
#define taskNOTIFICATION_RECEIVED   ( ( uint8_t ) 2 )
#define tskSTACK_FILL_BYTE   ( 0xa5U )
#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 0 )
#define tskSTATICALLY_ALLOCATED_STACK_ONLY   ( ( uint8_t ) 1 )
#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 2 )
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE   0
#define tskRUNNING_CHAR   ( 'X' )
#define tskBLOCKED_CHAR   ( 'B' )
#define tskREADY_CHAR   ( 'R' )
#define tskDELETED_CHAR   ( 'D' )
#define tskSUSPENDED_CHAR   ( 'S' )
#define configIDLE_TASK_NAME   "IDLE"
#define taskRECORD_READY_PRIORITY(uxPriority)
#define taskSELECT_HIGHEST_PRIORITY_TASK(xCoreID)
#define taskRESET_READY_PRIORITY(uxPriority)
#define portRESET_READY_PRIORITY(uxPriority, uxTopReadyPriority)
#define taskSWITCH_DELAYED_LISTS()
#define prvAddTaskToReadyList(pxTCB)
#define prvGetTCBFromHandle(pxHandle)
#define taskEVENT_LIST_ITEM_VALUE_IN_USE   ( ( uint16_t ) 0x8000U )
#define taskTASK_NOT_RUNNING   ( ( BaseType_t ) ( -1 ) )
#define taskTASK_SCHEDULED_TO_YIELD   ( ( BaseType_t ) ( -2 ) )
#define taskTASK_IS_RUNNING(pxTCB)
#define taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD(pxTCB)
#define taskATTRIBUTE_IS_IDLE   ( UBaseType_t ) ( 1U << 0U )
#define taskBITS_PER_BYTE   ( ( size_t ) 8 )
#define pxCurrentTCB   xTaskGetCurrentTaskHandle()

Typedefs

typedef struct tskTaskControlBlock tskTCB
typedef tskTCB TCB_t

Functions

static BaseType_t prvCreateIdleTasks (void)
static void prvInitialiseTaskLists (static void prvCheckTasksWaitingTermination void)
static void prvAddNewTaskToReadyList (TCB_t *pxNewTCB)
void vTaskStartScheduler (void)
void vTaskEndScheduler (void)
void vTaskSuspendAll (void)
BaseType_t xTaskResumeAll (void)
TickType_t xTaskGetTickCount (void)
TickType_t xTaskGetTickCountFromISR (void)
UBaseType_t uxTaskGetNumberOfTasks (void)
char * pcTaskGetName (TaskHandle_t xTaskToQuery)
BaseType_t xTaskCatchUpTicks (TickType_t xTicksToCatchUp)
BaseType_t xTaskIncrementTick (void)
void vTaskSwitchContext (BaseType_t xCoreID)
void vTaskPlaceOnEventList (List_t *const pxEventList, const TickType_t xTicksToWait)
void vTaskPlaceOnUnorderedEventList (List_t *pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait)
BaseType_t xTaskRemoveFromEventList (const List_t *const pxEventList)
void vTaskRemoveFromUnorderedEventList (ListItem_t *pxEventListItem, const TickType_t xItemValue)
void vTaskSetTimeOutState (TimeOut_t *const pxTimeOut)
void vTaskInternalSetTimeOutState (TimeOut_t *const pxTimeOut)
BaseType_t xTaskCheckForTimeOut (TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait)
void vTaskMissedYield (void)
static portTASK_FUNCTION (prvIdleTask, pvParameters)
static void prvInitialiseTaskLists (void)
static void prvCheckTasksWaitingTermination (void)
static void prvResetNextTaskUnblockTime (void)
TickType_t uxTaskResetEventItemValue (void)
static void prvAddCurrentTaskToDelayedList (TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely)
void vTaskResetState (void)

Variables

portDONT_DISCARD PRIVILEGED_DATA TCB_t *volatile pxCurrentTCBs [configNUMBER_OF_CORES]
static PRIVILEGED_DATA List_t pxReadyTasksLists [configMAX_PRIORITIES]
static PRIVILEGED_DATA List_t xDelayedTaskList1
static PRIVILEGED_DATA List_t xDelayedTaskList2
static PRIVILEGED_DATA List_t *volatile pxDelayedTaskList
static PRIVILEGED_DATA List_t *volatile pxOverflowDelayedTaskList
static PRIVILEGED_DATA List_t xPendingReadyList
static PRIVILEGED_DATA volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U
static PRIVILEGED_DATA volatile TickType_t xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT
static PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY
static PRIVILEGED_DATA volatile BaseType_t xSchedulerRunning = pdFALSE
static PRIVILEGED_DATA volatile TickType_t xPendedTicks = ( TickType_t ) 0U
static PRIVILEGED_DATA volatile BaseType_t xYieldPendings [configNUMBER_OF_CORES] = { pdFALSE }
static PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0
static PRIVILEGED_DATA UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U
static PRIVILEGED_DATA volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U
static PRIVILEGED_DATA TaskHandle_t xIdleTaskHandles [configNUMBER_OF_CORES]
static const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U
static PRIVILEGED_DATA volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) 0U

Macro Definition Documentation

◆ configIDLE_TASK_NAME

#define configIDLE_TASK_NAME   "IDLE"

◆ MPU_WRAPPERS_INCLUDED_FROM_API_FILE

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE

◆ portRESET_READY_PRIORITY

#define portRESET_READY_PRIORITY ( uxPriority,
uxTopReadyPriority )

◆ prvAddTaskToReadyList

#define prvAddTaskToReadyList ( pxTCB)
Value:
do { \
traceMOVED_TASK_TO_READY_STATE( pxTCB ); \
taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
listINSERT_END( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ); \
} while( 0 )
static PRIVILEGED_DATA List_t pxReadyTasksLists[configMAX_PRIORITIES]
Definition tasks.c:459

◆ prvGetTCBFromHandle

#define prvGetTCBFromHandle ( pxHandle)
Value:
( ( ( pxHandle ) == NULL ) ? pxCurrentTCB : ( pxHandle ) )
#define pxCurrentTCB
Definition tasks.c:452

◆ pxCurrentTCB

#define pxCurrentTCB   xTaskGetCurrentTaskHandle()

◆ taskATTRIBUTE_IS_IDLE

#define taskATTRIBUTE_IS_IDLE   ( UBaseType_t ) ( 1U << 0U )

◆ taskBITS_PER_BYTE

#define taskBITS_PER_BYTE   ( ( size_t ) 8 )

◆ taskEVENT_LIST_ITEM_VALUE_IN_USE

#define taskEVENT_LIST_ITEM_VALUE_IN_USE   ( ( uint16_t ) 0x8000U )

◆ taskNOT_WAITING_NOTIFICATION

#define taskNOT_WAITING_NOTIFICATION   ( ( uint8_t ) 0 ) /* Must be zero as it is the initialised value. */

◆ taskNOTIFICATION_RECEIVED

#define taskNOTIFICATION_RECEIVED   ( ( uint8_t ) 2 )

◆ taskRECORD_READY_PRIORITY

#define taskRECORD_READY_PRIORITY ( uxPriority)
Value:
do { \
if( ( uxPriority ) > uxTopReadyPriority ) \
{ \
uxTopReadyPriority = ( uxPriority ); \
} \
} while( 0 ) /* taskRECORD_READY_PRIORITY */
static PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority
Definition tasks.c:488

◆ taskRESET_READY_PRIORITY

#define taskRESET_READY_PRIORITY ( uxPriority)

◆ taskSELECT_HIGHEST_PRIORITY_TASK

#define taskSELECT_HIGHEST_PRIORITY_TASK ( xCoreID)
Value:
prvSelectHighestPriorityTask( xCoreID )

◆ taskSWITCH_DELAYED_LISTS

#define taskSWITCH_DELAYED_LISTS ( )
Value:
do { \
List_t * pxTemp; \
\
/* The delayed tasks list should be empty when the lists are switched. */ \
configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); \
\
pxTemp = pxDelayedTaskList; \
prvResetNextTaskUnblockTime(); \
} while( 0 )
#define listLIST_IS_EMPTY(pxList)
Definition list.h:258
struct xLIST List_t
long BaseType_t
Definition portmacro.h:59
static PRIVILEGED_DATA List_t *volatile pxOverflowDelayedTaskList
Definition tasks.c:463
static PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows
Definition tasks.c:492
static PRIVILEGED_DATA List_t *volatile pxDelayedTaskList
Definition tasks.c:462

◆ taskTASK_IS_RUNNING

#define taskTASK_IS_RUNNING ( pxTCB)
Value:
( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
#define configNUMBER_OF_CORES
Definition FreeRTOS.h:96
#define pdFALSE
Definition projdefs.h:52
#define pdTRUE
Definition projdefs.h:53

◆ taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD

#define taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD ( pxTCB)
Value:
( ( ( pxTCB )->xTaskRunState != taskTASK_NOT_RUNNING ) ? ( pdTRUE ) : ( pdFALSE ) )
#define taskTASK_NOT_RUNNING
Definition tasks.c:302

◆ taskTASK_NOT_RUNNING

#define taskTASK_NOT_RUNNING   ( ( BaseType_t ) ( -1 ) )

◆ taskTASK_SCHEDULED_TO_YIELD

#define taskTASK_SCHEDULED_TO_YIELD   ( ( BaseType_t ) ( -2 ) )

◆ taskWAITING_NOTIFICATION

#define taskWAITING_NOTIFICATION   ( ( uint8_t ) 1 )

◆ taskYIELD_ANY_CORE_IF_USING_PREEMPTION

#define taskYIELD_ANY_CORE_IF_USING_PREEMPTION ( pxTCB)

◆ taskYIELD_TASK_CORE_IF_USING_PREEMPTION

#define taskYIELD_TASK_CORE_IF_USING_PREEMPTION ( pxTCB)

◆ tskBLOCKED_CHAR

#define tskBLOCKED_CHAR   ( 'B' )

◆ tskDELETED_CHAR

#define tskDELETED_CHAR   ( 'D' )

◆ tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB

#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 0 )

◆ tskREADY_CHAR

#define tskREADY_CHAR   ( 'R' )

◆ tskRUNNING_CHAR

#define tskRUNNING_CHAR   ( 'X' )

◆ tskSET_NEW_STACKS_TO_KNOWN_VALUE

#define tskSET_NEW_STACKS_TO_KNOWN_VALUE   0

◆ tskSTACK_FILL_BYTE

#define tskSTACK_FILL_BYTE   ( 0xa5U )

◆ tskSTATICALLY_ALLOCATED_STACK_AND_TCB

#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB   ( ( uint8_t ) 2 )

◆ tskSTATICALLY_ALLOCATED_STACK_ONLY

#define tskSTATICALLY_ALLOCATED_STACK_ONLY   ( ( uint8_t ) 1 )

◆ tskSUSPENDED_CHAR

#define tskSUSPENDED_CHAR   ( 'S' )

Typedef Documentation

◆ TCB_t

typedef tskTCB TCB_t

◆ tskTCB

typedef struct tskTaskControlBlock tskTCB

Function Documentation

◆ pcTaskGetName()

char * pcTaskGetName ( TaskHandle_t xTaskToQuery)

◆ portTASK_FUNCTION()

portTASK_FUNCTION ( prvIdleTask ,
pvParameters  )
static

THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE SCHEDULER IS STARTED.

Here is the call graph for this function:

◆ prvAddCurrentTaskToDelayedList()

void prvAddCurrentTaskToDelayedList ( TickType_t xTicksToWait,
const BaseType_t xCanBlockIndefinitely )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prvAddNewTaskToReadyList()

void prvAddNewTaskToReadyList ( TCB_t * pxNewTCB)
static
Here is the call graph for this function:

◆ prvCheckTasksWaitingTermination()

void prvCheckTasksWaitingTermination ( void )
static

THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prvCreateIdleTasks()

BaseType_t prvCreateIdleTasks ( void )
static
Here is the caller graph for this function:

◆ prvInitialiseTaskLists() [1/2]

void prvInitialiseTaskLists ( static void prvCheckTasksWaitingTermination void)
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.

◆ prvInitialiseTaskLists() [2/2]

void prvInitialiseTaskLists ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prvResetNextTaskUnblockTime()

void prvResetNextTaskUnblockTime ( void )
static
Here is the caller graph for this function:

◆ uxTaskGetNumberOfTasks()

UBaseType_t uxTaskGetNumberOfTasks ( void )

◆ uxTaskResetEventItemValue()

TickType_t uxTaskResetEventItemValue ( void )

◆ vTaskEndScheduler()

void vTaskEndScheduler ( void )
Here is the call graph for this function:

◆ vTaskInternalSetTimeOutState()

void vTaskInternalSetTimeOutState ( TimeOut_t *const pxTimeOut)
Here is the caller graph for this function:

◆ vTaskMissedYield()

void vTaskMissedYield ( void )
Here is the caller graph for this function:

◆ vTaskPlaceOnEventList()

void vTaskPlaceOnEventList ( List_t *const pxEventList,
const TickType_t xTicksToWait )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vTaskPlaceOnUnorderedEventList()

void vTaskPlaceOnUnorderedEventList ( List_t * pxEventList,
const TickType_t xItemValue,
const TickType_t xTicksToWait )
Here is the call graph for this function:

◆ vTaskRemoveFromUnorderedEventList()

void vTaskRemoveFromUnorderedEventList ( ListItem_t * pxEventListItem,
const TickType_t xItemValue )
Here is the call graph for this function:

◆ vTaskResetState()

void vTaskResetState ( void )

◆ vTaskSetTimeOutState()

void vTaskSetTimeOutState ( TimeOut_t *const pxTimeOut)

◆ vTaskStartScheduler()

void vTaskStartScheduler ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vTaskSuspendAll()

void vTaskSuspendAll ( void )
Here is the caller graph for this function:

◆ vTaskSwitchContext()

void vTaskSwitchContext ( BaseType_t xCoreID)
Here is the caller graph for this function:

◆ xTaskCatchUpTicks()

BaseType_t xTaskCatchUpTicks ( TickType_t xTicksToCatchUp)
Here is the call graph for this function:

◆ xTaskCheckForTimeOut()

BaseType_t xTaskCheckForTimeOut ( TimeOut_t *const pxTimeOut,
TickType_t *const pxTicksToWait )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xTaskGetTickCount()

TickType_t xTaskGetTickCount ( void )
Here is the caller graph for this function:

◆ xTaskGetTickCountFromISR()

TickType_t xTaskGetTickCountFromISR ( void )

◆ xTaskIncrementTick()

BaseType_t xTaskIncrementTick ( void )
Here is the caller graph for this function:

◆ xTaskRemoveFromEventList()

BaseType_t xTaskRemoveFromEventList ( const List_t *const pxEventList)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xTaskResumeAll()

BaseType_t xTaskResumeAll ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pxCurrentTCBs

◆ pxDelayedTaskList

PRIVILEGED_DATA List_t* volatile pxDelayedTaskList
static

Points to the delayed task list currently being used.

◆ pxOverflowDelayedTaskList

PRIVILEGED_DATA List_t* volatile pxOverflowDelayedTaskList
static

Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count.

◆ pxReadyTasksLists

PRIVILEGED_DATA List_t pxReadyTasksLists[configMAX_PRIORITIES]
static

Prioritised ready tasks.

◆ uxCurrentNumberOfTasks

PRIVILEGED_DATA volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U
static

◆ uxSchedulerSuspended

PRIVILEGED_DATA volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) 0U
static

◆ uxTaskNumber

PRIVILEGED_DATA UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U
static

◆ uxTopReadyPriority

PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY
static

◆ uxTopUsedPriority

const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U
static

◆ xDelayedTaskList1

PRIVILEGED_DATA List_t xDelayedTaskList1
static

Delayed tasks.

◆ xDelayedTaskList2

PRIVILEGED_DATA List_t xDelayedTaskList2
static

Delayed tasks (two lists are used - one for delays that have overflowed the current tick count.

◆ xIdleTaskHandles

Holds the handles of the idle tasks. The idle tasks are created automatically when the scheduler is started.

◆ xNextTaskUnblockTime

PRIVILEGED_DATA volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U
static

◆ xNumOfOverflows

PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0
static

◆ xPendedTicks

PRIVILEGED_DATA volatile TickType_t xPendedTicks = ( TickType_t ) 0U
static

◆ xPendingReadyList

PRIVILEGED_DATA List_t xPendingReadyList
static

Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed.

◆ xSchedulerRunning

PRIVILEGED_DATA volatile BaseType_t xSchedulerRunning = pdFALSE
static

◆ xTickCount

◆ xYieldPendings

PRIVILEGED_DATA volatile BaseType_t xYieldPendings[configNUMBER_OF_CORES] = { pdFALSE }
static