I am trying to understand why there is a 0.5ms delay in a trace capture before the network task is switched to. I’m not sure how to ask this question exactly, so I’ll post the traces, see at 7.58.226.534 vTaskNotiveGiveFromISR(Network) where the isr fires, then the context switches to idle, then there are a number of Actor Readys with a delay I don’t understand, and Network doesn’t get switched to until 7.58.227.015.
So I’m trying to understand what FreeRTOS and or the CPU is doing in this time, and wondering how I can get this to switch quicker?
Not looked at the trace yet - but from a quick squizz at the code I see
you are not requesting the context switch from the ISR. If
xHigherPriorityTaskWoken is set to a non zero value inside
vTaskNotifyGiveFromISR() then a task that has a priority above that of
the currently executing task was unblocked and a context switch should
be performed. It is not done automatically to give you finer control
(consider not wanting to perform a context switch each time a character
in a stream was received).
The page I linked to before shows two methods of implementing an
interrupt that can cause a context switch. Which one are you using?
Also, now I have looked at the trace, I cannot see what is actually
executing, although I know you state it is the idle task. Are you using
an idle hook function?
I am using the wrapper, not exactly like the one you have, but copied from the Microchip harmony stack. So for the ISR above , I have this in the .S file
Ok - so the first thing to see is which task is actually running, as if
you are using this wrapper than the context switch should happen as you
come out of the interrupt handler. If you scroll to the left on the
trace you provided you should be able to see what is using the CPU time.
Then we can look into that task to see why it is preventing a context
switch.
Note, that xHignerPriorityTaskWoken is just a variable. The ISR needs to DO something with it to make anything happen. Unfortuanatly, it is somewhat port dependant on what this is. I suppose it would be nice if all the port supported something like
portEND_SWITCHING_ISR( xYieldRequired );
so it could be in the main documentation, but as far as I know that hasn’t been added to all of them.
portEND_SWITCHING_ISR( xYieldRequired );
so it could be in the main documentation, but as far as I know that
hasn’t been added to all of them.
Yes - I have referenced the page on the FreeRTOS.org website that has
examples of how to do this on a PIC32 in a couple of previous posts on
this thread - and there are examples in the download too.
Richard, my comment was that if ALL ports had portEND_SWITCHING_ISR(), then the main documentation, like for vTaskNotifyFromISR() could reference it, As it is, many example use it, but the main documentation tree doesn't have documentation for it, you need to look into the documentation for the port, which seems to trip up many people.
Is there any port that couldn't define the way to end an ISR to be that way?