(37)任务切换函数 vPortYield 原理,看来就是置位寄存器 SCB_ICSR -> PENDSET 标志位,以触发 pendSV()中断函数,就发起了任务切换:
portYIELD_WITHIN_API();// 这是应用#defineportYIELD_WITHIN_APIportYIELD#defineportYIELD()\// portmacro.h{\/* Set a PendSV to request a context switch. */\ portNVIC_INT_CTRL_REG=portNVIC_PENDSVSET_BIT;\ \__dsb(portSY_FULL_READ_WRITE);\__isb(portSY_FULL_READ_WRITE);\}// 通常不需要屏障,但应确保代码完全符合架构的指定行为。在架构规定的范围内。voidvPortYield(void)// 这是 vs2022 搜索出来的函数版本。 port.c{/* Set a PendSV to request a context switch. */portNVIC_INT_CTRL_REG=portNVIC_PENDSVSET_BIT;/* Barriers are normally not required but do ensure the code is completely * within the specified behaviour for the architecture. */__dsb(portSY_FULL_READ_WRITE);__isb(portSY_FULL_READ_WRITE);}(38)全局变量 uxTaskNumber(任务ID)与 uxCurrentNumberOfTasks(任务数量)的区别:
++空闲任务在 uxCurrentNumberOfTasks 的统计里面:
(39)
谢谢