Quality RTOS & Embedded Software

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




Loading

On Exit of vSoftwareInterruptHandler() p. 97

Posted by Joe Flowers on December 29, 2012
I am very curious to know what would happen if a line like vPrintString("xyz\n"); was added right after the portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); line in the vSoftwareInterruptHandler() function on page 97 of the "Using The FreeRTOS Real Time Kernel, NXP LPC17xx Edition" 2nd edition book?

Would "xyz" be printed out if xHigherPriorityTaskWoken is pdTRUE?
Would "xyz" be printed out if xHigherPriorityTaskWoken is pdFALSE?

Thanks!!!



RE: On Exit of vSoftwareInterruptHandler() p. 97

Posted by Joe Flowers on December 29, 2012
I found the answer. It prints out "xyz" in either case. The ISR ( vSoftwareInterruptHandler() ) is not interrupted or cut short by the
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); line.


RE: On Exit of vSoftwareInterruptHandler() p. 97

Posted by Richard on December 29, 2012
First, vPrintString() must not be called from an interrupt if it is using a critical section, locking the scheduler, or using any non ISR safe FreeRTOS function. As a general rule console IO is too slow for interrupts whatever the method.

I think your question relates more to the sequence of execution than printing in any case. On the Cortex-M3 based LPC17xx all context switches are performed in the PendSV interrupt, and the PendSV interrupt is always the lowest priority interrupt so will not itself interrupt the vSoftwareInterruptHandler() function.

If xHigherPriorityTaskIsWoken is pdTRUE then portEND_SWITCHING_ISR() will pend the PendSV interrupt, then any code that appears after the call to portEND_SWITCHING_ISR() macro will execute before the vSoftwareInterruptHandler() function exits. When the function exits the interrupt is complete and the PendSV interrupt handler can and will execute to perform the context switch before any task level code executes.

If xHigherPriorityTaskIsWoken is pdFALSE then portEND_SWITCHING_ISR() will not pend the PendSV interrupt, then any code that appears after the call to portEND_SWITCHING_ISR() macro will execute before the vSoftwareInterruptHandler() function exits.

This is true for the Cortex-M port, but not all the FreeRTOS ports.

Regards.


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




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

Latest News

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


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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