freeRTOS task switch

kuromame wrote on Sunday, May 26, 2019:

I think many RTOSs do switch in/out when system calls are called.
But freeRTOS does not switch in/out on system calls.
freeRTOS switches in/out in the followings.
1.a tick interruput occurs
2.a task become to be blocked
3.yield() etc.
Am i correct?

richarddamon wrote on Sunday, May 26, 2019:

I would say that most RTOSes I have used (for this class of processor) don’t use a context switch for calls into the OS. That sort of switch is needed for a ‘Protected Mode’ OS, where the OS runs in a higher privelidge state than most of the user program. FreeRTOS supports somethng like this in the MPU ports, where most system calls, if made within a restricted task, need to transition the system state to unrestricted.

In FreeRTOS, the following things will initiate a task switch,

  1. Any interrupt (including the tick) that unblocks a task so it becomes the highest priority task (or suspends the highest priority task) (only if preempton is enabled)
  2. The current running task blocks on something, delays itself, suspends itself or deletes itself. (Something to make it not able to run right now)
  3. The current running task yields (Will do a task switch to the next ready task of the same priority if there is one)
  4. The current running task makes some other task ready and of higher priority. (Will switch to the new highest priority task(

I think that is the complete list.

kuromame wrote on Sunday, May 26, 2019:

An expression was inaccurate for my question.
Your answer is what I wanted to know. I didn’t know that there is a condition of No.4 of your answer in FreeRTOS.
When a manual was read after having your response, I noticed being written on a manual this certainly. This No.1-No.4 also matches my former experience.
Thank you very much.

kuromame wrote on Sunday, May 26, 2019:

… deleted (duplecated)