This post describes RTOS threads (tasks) and interrupt behavior.
RTOS prioritizes processing with the highest priority as shown in the figure below. Therefore, low-priority processing may be delayed, as in the case of APLn+2.
1) Thread APLn activation of cycle T[ms]
2) Thread APLn+1 activation
3) Interrupt INT occurs during APLn+1 execution. Interrupts APLn+1 and executes interrupt INT
4) Interrupt INT terminated and returns to APLn+1
5) Start APLn+2 immediately after the end of APLn+1 because cycle T has elapsed.

Next, we explain the periodic averaging of RTOS time-period threads (TASK). One of the important functions of RTOS time-period Threads (TASK) is period averaging. Even if the processing time of a Thread is longer than the period, the next period can be shortened to prevent the Thread from missing processing and to make the Thread stable.
Time period averaging : ( tn+1 + tn+2 )/2 = T
Note : Tolerance (tn+2-T, T-tn+1) appears in the derivative and integral ⊿t of the control calculation.
