Hi all,
I have a simple data structure (stack implementation) and two or more tasks will use this stack in my system. They have different priorities and I need a synchronization mechanism. The first one come into my mind is semaphores, but I am thinking on alternatives. Therefore, I planned to use Task_disable/enable in order to protect critical sections between tasks. However, I have a scenario in my mind which is blurry for me if it is possible to happen.
Ex:
Assume that Task1 calls Task_disable and enters the critical section.
Then, Task2 (a higher priority task) wants to do something with stack, but have to wait for Task1 due to disabled task scheduler.
Before Task1 calling Task_enable() or even completing its task, a HWI preempts this task (Task1).
HWI completes its task and then returns to the task stack.
At that point which task will start? Task1 (which was running before the HWI), or Task2 (which has a higher priority)?
I looked at the source code in Task.c and Hwi.c and it seems that Task1 should be started in that case, but I am not sure. Moreover, is it the when a preempting thing is a SWI instead of HWI. Is it safe to use such a mechanism (Task_disable/enable) between tasks with different priorities?
Regards
SYS/BIOS 6.32.04.49 on EVM6678