Quality RTOS & Embedded Software

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


Message processing time

Posted by Richard on November 12, 2012
If I post a message from an ISR does that message get immediately processed by the RTOS and acted upon or does it only get acted upon at the next RTOS tick?

RE: Message processing time

Posted by Richard Damon on November 12, 2012
If the ISR activates the scheduler (The method is port specific) then a task waiting on the queue/semaphore the ISR acted on (if it is now the highest priority ready task) will be activated, otherwise it will need to wait for the next time the scheduler is activated, which should be no later than the next tick (assuming it becomes the highest priority waiting task).

RE: Message processing time

Posted by Richard on November 12, 2012
If you call a function from an interrupt that causes a task to unblock, and the task that unblocks has a priority above or equal to the currently running task, then the interrupt will return directly to the unblocked task if you tell it to.

Here is a generic example. Note this uses a macro call portEND_SWITCHING_ISR(). In some ports this is called portYIELD_FROM_ISR(), which does the same thing.

void Dummy_IRQHandler(void)
long lHigherPriorityTaskWoken = pdFALSE;

/* Clear the interrupt if necessary. */

/* This interrupt does nothing more than demonstrate how to synchronise a
task with an interrupt. A semaphore is used for this purpose. Note
lHigherPriorityTaskWoken is initialised to zero. */
xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken );

/* If there was a task that was blocked on the semaphore, and giving the
semaphore caused the task to unblock, and the unblocked task has a priority
higher than the current Running state task (the task that this interrupt
interrupted), then lHigherPriorityTaskWoken will have been set to pdTRUE
internally within xSemaphoreGiveFromISR(). Passing pdTRUE into the
portEND_SWITCHING_ISR() macro will result in a context switch being pended to
ensure this interrupt returns directly to the unblocked, higher priority,
task. Passing pdFALSE into portEND_SWITCHING_ISR() has no effect. */
portEND_SWITCHING_ISR( lHigherPriorityTaskWoken );


RE: Message processing time

Posted by Richard on November 12, 2012
Awesome - this is the first time I've needed to use the HigherPriorityTaskWoken flag and had forgotten about this behavior - that's most likely our issue.

If most of our tasks are at the same priority, then will returning TRUE cause a task of the same priority level (assuming it is running) to be immediately preempted?

Many thanks Richard.

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

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


FreeRTOS and other embedded software careers at AWS.

Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.

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

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