Marvee Amasi
Marvee Amasi
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 5/6/2024 in #middleware-and-os
Memory Operations During Context Switch: Impact on Priority Tasks?
Hi @Middleware & OS I have two tasks, A and B, with A being high priority and B low priority. There are two global variables, condition and mem. Let's say Task B is currently running and performing memory operations. If Task A becomes ready while Task B is running, resulting in a context switch, will the memory operation continue even if the condition is set to false? If so, at which index will it restart? And what will the content of mem be after Task B finishes executing?
***Task B - Low priority task ***
if (condition) {
.....
for (i = 0; i< 10; i++){
// example we are at i=4
mem[i] = mem[i] +1;
}
.....
}
***Task B - Low priority task ***
if (condition) {
.....
for (i = 0; i< 10; i++){
// example we are at i=4
mem[i] = mem[i] +1;
}
.....
}
And
*** TASK A - High priority task
***
......
enter_critical();
condition = false;
mem[i] = 0;
exit_critical();
......
*** TASK A - High priority task
***
......
enter_critical();
condition = false;
mem[i] = 0;
exit_critical();
......
now Task A is finshed and yields resources for Task B to run.
6 replies