This post describes why inter-task and interrupt-to-task communication is necessary in multitasking.
The reason for the need for inter-task and interrupt-to-task communication in a multitasking OS with different priorities is that updating information in the interface variable of a lower task by a higher task or interrupt while the lower task is executing may cause inconsistencies in the processing of the lower task, as shown in the figure below.
To avoid this problem, inter-task and interrupt-to-task communication is required. Specifically, the interface variable from the upper task or interrupt to the lower task should be Read in one place (Receive Copy in the figure below) and the interface variable from the lower task to the upper task or interrupt should be Write in one place (Send Copy in the figure below). In addition, for the Receive and Send copies shown in the figure, it is necessary to perform interrupt disable processing, etc., in consideration of the interface variables that are linked.
![](https://oss-ecal.com/wp-content/uploads/2024/05/interrupt-to-task-communication_EN.png)