MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / prvAddCurrentTaskToDelayedList

Function prvAddCurrentTaskToDelayedList

tasks.c:6224–6334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6222/*-----------------------------------------------------------*/
6223
6224static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
6225 const BaseType_t xCanBlockIndefinitely )
6226{
6227 TickType_t xTimeToWake;
6228 const TickType_t xConstTickCount = xTickCount;
6229
6230 #if ( INCLUDE_xTaskAbortDelay == 1 )
6231 {
6232 /* About to enter a delayed list, so ensure the ucDelayAborted flag is
6233 * reset to pdFALSE so it can be detected as having been set to pdTRUE
6234 * when the task leaves the Blocked state. */
6235 pxCurrentTCB->ucDelayAborted = pdFALSE;
6236 }
6237 #endif
6238
6239 /* Remove the task from the ready list before adding it to the blocked list
6240 * as the same list item is used for both lists. */
6241 if( uxListRemove( &( pxCurrentTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
6242 {
6243 /* The current task must be in a ready list, so there is no need to
6244 * check, and the port reset macro can be called directly. */
6245 portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); /*lint !e931 pxCurrentTCB cannot change as it is the calling task. pxCurrentTCB->uxPriority and uxTopReadyPriority cannot change as called with scheduler suspended or in a critical section. */
6246 }
6247 else
6248 {
6249 mtCOVERAGE_TEST_MARKER();
6250 }
6251
6252 #if ( INCLUDE_vTaskSuspend == 1 )
6253 {
6254 if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) )
6255 {
6256 /* Add the task to the suspended task list instead of a delayed task
6257 * list to ensure it is not woken by a timing event. It will block
6258 * indefinitely. */
6259 vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) );
6260 }
6261 else
6262 {
6263 /* Calculate the time at which the task should be woken if the event
6264 * does not occur. This may overflow but this doesn't matter, the
6265 * kernel will manage it correctly. */
6266 xTimeToWake = xConstTickCount + xTicksToWait;
6267
6268 /* The list item will be inserted in wake time order. */
6269 listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake );
6270
6271 if( xTimeToWake < xConstTickCount )
6272 {
6273 /* Wake time has overflowed. Place this item in the overflow
6274 * list. */
6275 vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
6276 }
6277 else
6278 {
6279 /* The wake time has not overflowed, so the current block list
6280 * is used. */
6281 vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );

Callers 7

xTaskDelayUntilFunction · 0.85
vTaskDelayFunction · 0.85
vTaskPlaceOnEventListFunction · 0.85
ulTaskGenericNotifyTakeFunction · 0.85
xTaskGenericNotifyWaitFunction · 0.85

Calls 3

uxListRemoveFunction · 0.85
vListInsertEndFunction · 0.85
vListInsertFunction · 0.85

Tested by

no test coverage detected