Skip to content

File tasks.c

FileList > FreeRTOS > src > tasks.c

Go to the source code of this file.

  • #include <stdlib.h>
  • #include <string.h>
  • #include "FreeRTOS.h"
  • #include "task.h"
  • #include "timers.h"
  • #include "stack_macros.h"

Classes

Type Name
struct tskTaskControlBlock

Public Types

Type Name
typedef tskTCB TCB_t
typedef struct tskTaskControlBlock tskTCB

Public Attributes

Type Name
PRIVILEGED_DATA TCB_t *volatile pxCurrentTCB = = NULL

Public Static Attributes

Type Name
PRIVILEGED_DATA List_t *volatile pxDelayedTaskList
PRIVILEGED_DATA List_t *volatile pxOverflowDelayedTaskList
PRIVILEGED_DATA List_t pxReadyTasksLists
PRIVILEGED_DATA volatile UBaseType_t uxCurrentNumberOfTasks = = ( UBaseType_t ) 0U
PRIVILEGED_DATA volatile UBaseType_t uxSchedulerSuspended = = ( UBaseType_t ) pdFALSE
PRIVILEGED_DATA UBaseType_t uxTaskNumber = = ( UBaseType_t ) 0U
PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority = = tskIDLE_PRIORITY
PRIVILEGED_DATA List_t xDelayedTaskList1
PRIVILEGED_DATA List_t xDelayedTaskList2
PRIVILEGED_DATA TaskHandle_t xIdleTaskHandle = = NULL
PRIVILEGED_DATA volatile TickType_t xNextTaskUnblockTime = = ( TickType_t ) 0U
PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows = = ( BaseType_t ) 0
PRIVILEGED_DATA volatile TickType_t xPendedTicks = = ( TickType_t ) 0U
PRIVILEGED_DATA List_t xPendingReadyList
PRIVILEGED_DATA volatile BaseType_t xSchedulerRunning = = pdFALSE
PRIVILEGED_DATA volatile TickType_t xTickCount = = ( TickType_t ) configINITIAL_TICK_COUNT
PRIVILEGED_DATA volatile BaseType_t xYieldPending = = pdFALSE

Public Functions

Type Name
char * pcTaskGetName (TaskHandle_t xTaskToQuery)
UBaseType_t uxTaskGetNumberOfTasks (void)
TickType_t uxTaskResetEventItemValue (void)
void vTaskEndScheduler (void)
void vTaskInternalSetTimeOutState (TimeOut_t *const pxTimeOut)
void vTaskMissedYield (void)
void vTaskPlaceOnEventList (List_t *const pxEventList, const TickType_t xTicksToWait)
void vTaskPlaceOnUnorderedEventList (List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait)
void vTaskRemoveFromUnorderedEventList (ListItem_t * pxEventListItem, const TickType_t xItemValue)
void vTaskSetTimeOutState (TimeOut_t *const pxTimeOut)
void vTaskStartScheduler (void)
void vTaskSuspendAll (void)
void vTaskSwitchContext (void)
BaseType_t xTaskCatchUpTicks (TickType_t xTicksToCatchUp)
BaseType_t xTaskCheckForTimeOut (TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait)
TickType_t xTaskGetTickCount (void)
TickType_t xTaskGetTickCountFromISR (void)
BaseType_t xTaskIncrementTick (void)
BaseType_t xTaskRemoveFromEventList (const List_t *const pxEventList)
BaseType_t xTaskResumeAll (void)

Public Static Functions

Type Name
static portTASK_FUNCTION (prvIdleTask, pvParameters)
void prvAddCurrentTaskToDelayedList (TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely)
void prvAddNewTaskToReadyList (TCB_t * pxNewTCB)
void prvCheckTasksWaitingTermination (void)
void prvInitialiseTaskLists (static void prvCheckTasksWaitingTermination void void)
void prvInitialiseTaskLists (void)
void prvResetNextTaskUnblockTime (void)

Macros

Type Name
define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
define configIDLE_TASK_NAME "IDLE"
define portRESET_READY_PRIORITY (uxPriority, uxTopReadyPriority)
define prvAddTaskToReadyList (pxTCB)
define prvGetTCBFromHandle (pxHandle) ( ( ( pxHandle ) == NULL ) ? pxCurrentTCB : ( pxHandle ) )
define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL
define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )
define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )
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 ()
define tskBLOCKED_CHAR ( 'B' )
define tskDELETED_CHAR ( 'D' )
define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 )
define tskREADY_CHAR ( 'R' )
define tskRUNNING_CHAR ( 'X' )
define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0
define tskSTACK_FILL_BYTE ( 0xa5U )
define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 )
define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 )
define tskSUSPENDED_CHAR ( 'S' )

Public Types Documentation

typedef TCB_t

typedef tskTCB TCB_t;

typedef tskTCB

typedef struct tskTaskControlBlock tskTCB;

Public Attributes Documentation

variable pxCurrentTCB

PRIVILEGED_DATA TCB_t* volatile pxCurrentTCB;

Public Static Attributes Documentation

variable pxDelayedTaskList

PRIVILEGED_DATA List_t* volatile pxDelayedTaskList;

variable pxOverflowDelayedTaskList

PRIVILEGED_DATA List_t* volatile pxOverflowDelayedTaskList;

variable pxReadyTasksLists

PRIVILEGED_DATA List_t pxReadyTasksLists[configMAX_PRIORITIES];

variable uxCurrentNumberOfTasks

PRIVILEGED_DATA volatile UBaseType_t uxCurrentNumberOfTasks;

variable uxSchedulerSuspended

PRIVILEGED_DATA volatile UBaseType_t uxSchedulerSuspended;

variable uxTaskNumber

PRIVILEGED_DATA UBaseType_t uxTaskNumber;

variable uxTopReadyPriority

PRIVILEGED_DATA volatile UBaseType_t uxTopReadyPriority;

variable xDelayedTaskList1

PRIVILEGED_DATA List_t xDelayedTaskList1;

variable xDelayedTaskList2

PRIVILEGED_DATA List_t xDelayedTaskList2;

variable xIdleTaskHandle

PRIVILEGED_DATA TaskHandle_t xIdleTaskHandle;

variable xNextTaskUnblockTime

PRIVILEGED_DATA volatile TickType_t xNextTaskUnblockTime;

variable xNumOfOverflows

PRIVILEGED_DATA volatile BaseType_t xNumOfOverflows;

variable xPendedTicks

PRIVILEGED_DATA volatile TickType_t xPendedTicks;

variable xPendingReadyList

PRIVILEGED_DATA List_t xPendingReadyList;

variable xSchedulerRunning

PRIVILEGED_DATA volatile BaseType_t xSchedulerRunning;

variable xTickCount

PRIVILEGED_DATA volatile TickType_t xTickCount;

variable xYieldPending

PRIVILEGED_DATA volatile BaseType_t xYieldPending;

Public Functions Documentation

function pcTaskGetName

char * pcTaskGetName (
    TaskHandle_t xTaskToQuery
) 

function uxTaskGetNumberOfTasks

UBaseType_t uxTaskGetNumberOfTasks (
    void
) 

function uxTaskResetEventItemValue

TickType_t uxTaskResetEventItemValue (
    void
) 

function vTaskEndScheduler

void vTaskEndScheduler (
    void
) 

function vTaskInternalSetTimeOutState

void vTaskInternalSetTimeOutState (
    TimeOut_t *const pxTimeOut
) 

function vTaskMissedYield

void vTaskMissedYield (
    void
) 

function vTaskPlaceOnEventList

void vTaskPlaceOnEventList (
    List_t *const pxEventList,
    const TickType_t xTicksToWait
) 

function vTaskPlaceOnUnorderedEventList

void vTaskPlaceOnUnorderedEventList (
    List_t * pxEventList,
    const TickType_t xItemValue,
    const TickType_t xTicksToWait
) 

function vTaskRemoveFromUnorderedEventList

void vTaskRemoveFromUnorderedEventList (
    ListItem_t * pxEventListItem,
    const TickType_t xItemValue
) 

function vTaskSetTimeOutState

void vTaskSetTimeOutState (
    TimeOut_t *const pxTimeOut
) 

function vTaskStartScheduler

void vTaskStartScheduler (
    void
) 

function vTaskSuspendAll

void vTaskSuspendAll (
    void
) 

function vTaskSwitchContext

void vTaskSwitchContext (
    void
) 

function xTaskCatchUpTicks

BaseType_t xTaskCatchUpTicks (
    TickType_t xTicksToCatchUp
) 

function xTaskCheckForTimeOut

BaseType_t xTaskCheckForTimeOut (
    TimeOut_t *const pxTimeOut,
    TickType_t *const pxTicksToWait
) 

function xTaskGetTickCount

TickType_t xTaskGetTickCount (
    void
) 

function xTaskGetTickCountFromISR

TickType_t xTaskGetTickCountFromISR (
    void
) 

function xTaskIncrementTick

BaseType_t xTaskIncrementTick (
    void
) 

function xTaskRemoveFromEventList

BaseType_t xTaskRemoveFromEventList (
    const List_t *const pxEventList
) 

function xTaskResumeAll

BaseType_t xTaskResumeAll (
    void
) 

Public Static Functions Documentation

function portTASK_FUNCTION

static static portTASK_FUNCTION (
    prvIdleTask,
    pvParameters
) 

function prvAddCurrentTaskToDelayedList

static void prvAddCurrentTaskToDelayedList (
    TickType_t xTicksToWait,
    const BaseType_t xCanBlockIndefinitely
) 

function prvAddNewTaskToReadyList

static void prvAddNewTaskToReadyList (
    TCB_t * pxNewTCB
) 

function prvCheckTasksWaitingTermination

static void prvCheckTasksWaitingTermination (
    void
) 

function prvInitialiseTaskLists

static void prvInitialiseTaskLists (
    static void prvCheckTasksWaitingTermination void void
) 

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.

function prvInitialiseTaskLists

static void prvInitialiseTaskLists (
    void
) 

function prvResetNextTaskUnblockTime

static void prvResetNextTaskUnblockTime (
    void
) 

Macro Definition Documentation

define MPU_WRAPPERS_INCLUDED_FROM_API_FILE

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 

define configIDLE_TASK_NAME

#define configIDLE_TASK_NAME "IDLE"

define portRESET_READY_PRIORITY

#define portRESET_READY_PRIORITY (
    uxPriority,
    uxTopReadyPriority
) 

define prvAddTaskToReadyList

#define prvAddTaskToReadyList (
    pxTCB
) traceMOVED_TASK_TO_READY_STATE( pxTCB );                                                      \
    taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                             \
    vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
    tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )

define prvGetTCBFromHandle

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

define taskEVENT_LIST_ITEM_VALUE_IN_USE

#define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL

define taskNOTIFICATION_RECEIVED

#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )

define taskNOT_WAITING_NOTIFICATION

#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )

define taskRECORD_READY_PRIORITY

#define taskRECORD_READY_PRIORITY (
    uxPriority
) {                                                                                                 \
        if( ( uxPriority ) > uxTopReadyPriority )                                                       \
        {                                                                                               \
            uxTopReadyPriority = ( uxPriority );                                                        \
        }                                                                                               \
    } /* taskRECORD_READY_PRIORITY */

define taskRESET_READY_PRIORITY

#define taskRESET_READY_PRIORITY (
    uxPriority
) 

define taskSELECT_HIGHEST_PRIORITY_TASK

#define taskSELECT_HIGHEST_PRIORITY_TASK (

) {                                                                                                 \
    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. */                                  \
        listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) );           \
        uxTopReadyPriority = uxTopPriority;                                                             \
    } /* taskSELECT_HIGHEST_PRIORITY_TASK */

define taskSWITCH_DELAYED_LISTS

#define taskSWITCH_DELAYED_LISTS (

) {                                                                                                 \ List_t *pxTemp;                                                                                   \
                                                                                                    \
    /* The delayed tasks list should be empty when the lists are switched. */                       \
    configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) );                                     \
                                                                                                    \
    pxTemp = pxDelayedTaskList;                                                                     \
    pxDelayedTaskList = pxOverflowDelayedTaskList;                                                  \
    pxOverflowDelayedTaskList = pxTemp;                                                             \
    xNumOfOverflows++;                                                                              \
    prvResetNextTaskUnblockTime();                                                                  \
}

define taskWAITING_NOTIFICATION

#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )

define taskYIELD_IF_USING_PREEMPTION

#define taskYIELD_IF_USING_PREEMPTION (

) 

define tskBLOCKED_CHAR

#define tskBLOCKED_CHAR ( 'B' )

define tskDELETED_CHAR

#define tskDELETED_CHAR ( 'D' )

define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB

#define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 )

define tskREADY_CHAR

#define tskREADY_CHAR ( 'R' )

define tskRUNNING_CHAR

#define tskRUNNING_CHAR ( 'X' )

define tskSET_NEW_STACKS_TO_KNOWN_VALUE

#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0

define tskSTACK_FILL_BYTE

#define tskSTACK_FILL_BYTE ( 0xa5U )

define tskSTATICALLY_ALLOCATED_STACK_AND_TCB

#define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 )

define tskSTATICALLY_ALLOCATED_STACK_ONLY

#define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 )

define tskSUSPENDED_CHAR

#define tskSUSPENDED_CHAR ( 'S' )

The documentation for this class was generated from the following file fw/rbcx-coprocessor/lib/FreeRTOS/src/tasks.c