Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

configUSE_TICKLESS_IDLE mode vs interrupts

Posted by dumont02 on May 29, 2015

We are looking for reducing power consumption in our PIC24F freeRTos application.

For reducing power consumption, we are currently looking for using the configUSETICKLESSIDLE freeRtos option. Since the current pic24f port does not support it yet, I was looking at adding the required portSUPPRESSTICKSAND_SLEEP() macro myself based on instructions provided on the freeRtos Low Power website (http://www.freertos.org/low-power-tickless-rtos.html).

There something I must be missing though. On that website, it says:

To avoid race conditions the RTOS scheduler is suspended before portSUPPRESSTICKSANDSLEEP() is called, and resumed when portSUPPRESSTICKSANDSLEEP() completes. This ensures application tasks cannot execute between the microcontroller exiting its low power state and portSUPPRESSTICKSAND_SLEEP() completing its execution.

It also says in the example implementation of portSUPPRESSTICKSANDSLEEP(): >/* Determine how long the microcontroller was actually in a low power state for, which will be less than xExpectedIdleTime if the microcontroller was brought out of low power mode by an interrupt other than that configured by the vSetWakeTimeInterrupt() call. Note that the scheduler is suspended before portSUPPRESSTICKSANDSLEEP() is called, and resumed when portSUPPRESSTICKSAND_SLEEP() returns. Therefore no other tasks will execute until this function completes. */ ulLowPowerTimeAfterSleep = ulGetExternalTime();

Finally, from the vTaskSuspendAll() description: >API functions that have the potential to cause a context switch (for example, vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler is suspended.

Based on these previous citations, I can't understand how it can work when an other interrupt wakes up the cpu. Let's say I have a uart RX interrupt waking up the CPU, which calls taskYIELD() as recommended by freeRtos guidelines about ISR. Then it would perform a task context change going against the vTaskSuspendAll() documentation, right? Am I missing something or we really cannot use portSUPPRESSTICKSAND_SLEEP() when we have interrupts using freeRtos services that may provoke a task context?

Thanks for your help


configUSE_TICKLESS_IDLE mode vs interrupts

Posted by rtel on May 29, 2015

When the scheduler is suspended interrupts remain enabled. When the interrupt comes in the interrupt service routine executes and calls for a re-schedule to switch to another task. The re-schedule code then executes, but seeing the scheduler is suspended it does not actually perform the context switch, but instead holds it pending. The ISR then exits back to the task code. The task, which was in the supporess-ticks-and-sleep function, exits the function, at which point the scheduler is unsuspended. Inside the function that unsuspends the scheduler it is recognised that a context switch is pending, and the context switch is performed immediately that the scheduler is no longer suspended.

Does that answer your question?

Regards.


configUSE_TICKLESS_IDLE mode vs interrupts

Posted by dumont02 on May 30, 2015

Ok, makes sense! So if my understanding is correct, the statement in the vTaskSuspendAll() api doc >API functions that have the potential to cause a context switch (for example, vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler is suspended

is inaccurate since task context switch will simply pend until scheduler is resumed?


configUSE_TICKLESS_IDLE mode vs interrupts

Posted by richard_damon on May 30, 2015

I think the limitation is that the task that calls vTaskSuspendAll() shouldn't call something that will cause a context switch, but FreeRTOS handles the cases where the request occurs inside an ISR.

One way to think of it is it is contradictory to both request no scheduling and at the same time do an operation that needs to schedule another task to perform.


configUSE_TICKLESS_IDLE mode vs interrupts

Posted by dumont02 on May 30, 2015

Ok I understand. Many thanks for your clarifications!


configUSE_TICKLESS_IDLE mode vs interrupts

Posted by rtel on June 1, 2015

No, the statement is correct, API functions that have the potential to cause a context switch must not be called when the scheduler is suspended as they function will return when it should not and there will be a logic error. That is very different to an interrupt attempting to cause a context switch, and having the context switch held pending.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner