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

Function prvProcessTimerOrBlockTask

timers.c:625–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623/*-----------------------------------------------------------*/
624
625 static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime,
626 BaseType_t xListWasEmpty )
627 {
628 TickType_t xTimeNow;
629 BaseType_t xTimerListsWereSwitched;
630
631 vTaskSuspendAll();
632 {
633 /* Obtain the time now to make an assessment as to whether the timer
634 * has expired or not. If obtaining the time causes the lists to switch
635 * then don't process this timer as any timers that remained in the list
636 * when the lists were switched will have been processed within the
637 * prvSampleTimeNow() function. */
638 xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );
639
640 if( xTimerListsWereSwitched == pdFALSE )
641 {
642 /* The tick count has not overflowed, has the timer expired? */
643 if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) )
644 {
645 ( void ) xTaskResumeAll();
646 prvProcessExpiredTimer( xNextExpireTime, xTimeNow );
647 }
648 else
649 {
650 /* The tick count has not overflowed, and the next expire
651 * time has not been reached yet. This task should therefore
652 * block to wait for the next expire time or a command to be
653 * received - whichever comes first. The following line cannot
654 * be reached unless xNextExpireTime > xTimeNow, except in the
655 * case when the current timer list is empty. */
656 if( xListWasEmpty != pdFALSE )
657 {
658 /* The current timer list is empty - is the overflow list
659 * also empty? */
660 xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList );
661 }
662
663 vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty );
664
665 if( xTaskResumeAll() == pdFALSE )
666 {
667 /* Yield to wait for either a command to arrive, or the
668 * block time to expire. If a command arrived between the
669 * critical section being exited and this yield then the yield
670 * will not cause the task to block. */
671 vTaskYieldWithinAPI();
672 }
673 else
674 {
675 mtCOVERAGE_TEST_MARKER();
676 }
677 }
678 }
679 else
680 {
681 ( void ) xTaskResumeAll();
682 }

Callers 1

timers.cFile · 0.85

Calls 6

vTaskSuspendAllFunction · 0.85
prvSampleTimeNowFunction · 0.85
xTaskResumeAllFunction · 0.85
prvProcessExpiredTimerFunction · 0.85
vTaskYieldWithinAPIFunction · 0.85

Tested by

no test coverage detected