Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists