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

Function xTaskDelayUntil

tasks.c:1765–1846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1763#if ( INCLUDE_xTaskDelayUntil == 1 )
1764
1765 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
1766 const TickType_t xTimeIncrement )
1767 {
1768 TickType_t xTimeToWake;
1769 BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;
1770
1771 configASSERT( pxPreviousWakeTime );
1772 configASSERT( ( xTimeIncrement > 0U ) );
1773
1774 vTaskSuspendAll();
1775 {
1776 configASSERT( uxSchedulerSuspended == 1 );
1777
1778 /* Minor optimisation. The tick count cannot change in this
1779 * block. */
1780 const TickType_t xConstTickCount = xTickCount;
1781
1782 /* Generate the tick time at which the task wants to wake. */
1783 xTimeToWake = *pxPreviousWakeTime + xTimeIncrement;
1784
1785 if( xConstTickCount < *pxPreviousWakeTime )
1786 {
1787 /* The tick count has overflowed since this function was
1788 * lasted called. In this case the only time we should ever
1789 * actually delay is if the wake time has also overflowed,
1790 * and the wake time is greater than the tick time. When this
1791 * is the case it is as if neither time had overflowed. */
1792 if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) )
1793 {
1794 xShouldDelay = pdTRUE;
1795 }
1796 else
1797 {
1798 mtCOVERAGE_TEST_MARKER();
1799 }
1800 }
1801 else
1802 {
1803 /* The tick time has not overflowed. In this case we will
1804 * delay if either the wake time has overflowed, and/or the
1805 * tick time is less than the wake time. */
1806 if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) )
1807 {
1808 xShouldDelay = pdTRUE;
1809 }
1810 else
1811 {
1812 mtCOVERAGE_TEST_MARKER();
1813 }
1814 }
1815
1816 /* Update the wake time ready for the next call. */
1817 *pxPreviousWakeTime = xTimeToWake;
1818
1819 if( xShouldDelay != pdFALSE )
1820 {
1821 traceTASK_DELAY_UNTIL( xTimeToWake );
1822

Callers 1

MPU_xTaskDelayUntilFunction · 0.85

Calls 4

vTaskSuspendAllFunction · 0.85
xTaskResumeAllFunction · 0.85
vTaskYieldWithinAPIFunction · 0.85

Tested by

no test coverage detected