I have three operations. Each operation is in a loop and has a flag value that decreases when the operation is running. While the operation is running, any other operation with the flag value reaching the maximum threshold should interrupt it and run instead (has the highest priority). The flag value changes according to a differential equation against time.
- I want each operation’s
flagvalue to increase when another operation is running, and signal the system to switch to it when theflagvalue reaches the maximum threshold. - The
flagvalue of each operation increases and decreases according to a specific differential equation that changes with time when the operation is running.
All operations are currently in one file, looped in a Switch case statement. The current code is :
while 1
[value, index]=max(flag);
switch index
case 1
operation1
...
...
flag = [x y z]
case 2
operation2
...
...
flag = [x y z]
case 3
operation3
...
...
flag = [x y z]
end
end
Any ideas ? If you need me to explain a bit better then please do tell me.
There are several approaches here
Each requires a different solution
Here are some suggested solutions, for the corresponding problems:
ticandtoc), increase the flag of all other operations with this value.