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] [December 2012 Threads] On Exit of vSoftwareInterruptHandler() p. 97Posted 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. 97Posted 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. 97Posted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|