I have been using portEND_SWITCHING_ISR() but I was looking at various posts in the forum and online and I came across all these that seem to be used interchangeably:


Couple of questions:

  1. what is the difference between the three?
  2. which one should I use and why?

Thank you :slight_smile:

portEND_SWITCHING_ISR() adds the test of the parameter, and if set does the yield.

taskYIELD_FROM_ISR is the more ‘public’ version coming out of tasks.h instead of port.h, so tends to be a bit better, but all it does is expand as portYIELD_FROM_ISR().

If you look at the source code you will find taskYIELD() calls portYIELD(), so they are the same. Then looking at the online documentation you will note the macro naming convention to see why this is.

Thank you both,
I tried to find taskYIELD_FROM_ISR() API on the freeRTOS website and also in the book but couldn’t. The compiler does not recognise it and cannot find it in all the freeRTOS files I can search. So not sure which header I need to include?

To find the taskYIELD_FROM_ISR() details, I also tried Google (specifying the freeRTOS site) but it provides only results from the forum. A number of times previously has been difficult to find some macros description. What is the best/easiest way to do that? There must be a simple organized logic but cannot see one at the moment.

Also it seems that portYIELD_FROM_ISR() and portEND_SWITCHING_ISR() are the same thing just for different ports. And taskYIELD_FROM_ISR() would call the appropriate one automatically. Is that correct?

Thank you

Things that begin with port, come from the port layer, and some of them may differ in what they do and if they are defined from port to port, and things that begin with task are defined in task.h and are consistent from port to port.

Looks like there is no definition for taskYIELD_FROM_ISR(), (just a taskYIELD() )so you need to look in the port.h file for you system to see what options you have. I think all ports will have a portYIELD() that will be used by taskYIELD() to make it officially a universal macro, and most will have a portYIELD_FROM_ISR() macro to use inside an ISR. ISR are inherently somewhat processor specific, so having them use port specific code is reasonable. Some processors just have a portYIELD() and define that ISR will use that maybe with some restrictions on how it is used (like it needs to be the very last thing in the ISR).

portEND_SWITCHING_ISR(x) is a common macro for ending and ISR which bundles the test of the wasWoken flag. I know that at least at one point, some ports did not have that macro, so you needed to do the test yourself (or define you own version of the macro).

Thank you Richard :slight_smile: