Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix context switch for Cortex-M3/M4/M4F/M7 etc
Sometimes `PendSV` interrupt didn't fire immediately after setting `PENDSVSET` bit on cortex-m7. It causes problems in `tn_eventgrp_wait` function because it reaches `rc = _tn_curr_run_task->task_wait_rc;` line before the interrupt fires, and we get incorrect wait result. This commit fixes it by adding barriers (`dsb` and `isb`) before returning from `_tn_arch_context_switch_pend()`, as recommended by https://developer.arm.com/documentation/107565/0101/Memory-system/Memory-barriers/When-do-you-need-a-DSB-followed-by-an-ISB- > If a pended interrupt request needs to be recognized immediately after > being enabled in the NVIC, a `DSB` instruction followed by an `ISB` > instruction is recommended. The `DSB` instruction ensures that the write > to the NVIC enable register is complete, while the `ISB` instruction > ensures that IRQ is executed.
- Loading branch information