This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
一般来说,RTOS不会保存硬件乘法器的状态,所以如果乘法任务使用了硬件乘法器的话,必须通过阻止任务的切换来保护这些操作。比较常见的作法是阻止操作期间的中断。这可能很棘手,因为有时编译器会在没有可见的显式乘法运算符的情况下使用它。
GCC中有关-mhwmult操作的描述:
"The hardware multiply routines disable interrupts whilst running
and restore the previous interrupt state when they finish. This
makes them safe to use inside interrupt handlers as well as in
normal code."
所以使用GCC生成的代码是没问题的。但是其它编译器就难说。
如果您直接访问乘法器,比如运行扩展的乘法累加运算,您就需要保护它。