FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2015 Threads] configUSE_TICKLESS_IDLE mode vs interruptsPosted 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 interruptsPosted 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 interruptsPosted 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 interruptsPosted 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 interruptsPosted by dumont02 on May 30, 2015 Ok I understand. Many thanks for your clarifications!
configUSE_TICKLESS_IDLE mode vs interruptsPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|