I have a SysTick interrupt to trigger task switch 4 times per second, as shown below.
void SysTick_Handler(void) {
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk; // Set PendSV
}
The tasks in the main are occasionally outputting some messages via one of the UART, and to ensure that they have exclusive I/O access, the output routines are protected with a mutex that is set with LDREX and STREX. Code works perfectly well over 90% of the time.
However, one side effect of that protection appears to be that when SysTick happens during the period when the mutex is set, the task switch will not happen, and the task that was running at that time will continue to run until the next task switch.
Is there a way to trigger SysTick again, say, 10 ms later, and do that until the mutex is cleared by the currently running task? For example:
void SysTick_Handler(void) {
if (mutex) {
// set SysTick to trigger again in 10 ms
} else {
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk; // Set PendSV
}
}
If yes, how.
TIA
question from:
https://stackoverflow.com/questions/65927739/re-issue-systick-interrupt 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…