#if OS_SCHED_LOCK_EN > 0 |
void OSSchedLock (void) |
{ |
#if |
OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ |
OS_CPU_SR cpu_sr; |
#endif |
if (OSRunning == TRUE) { /* 确保多任务已经启动,调用过OSStart() */ |
OS_ENTER_CRITICAL(); |
if (OSLockNesting < 255) { /*OSLockNesting 为字节变量,确认嵌套没越界(255) */ |
OSLockNesting++; /* 锁嵌套+1 */ |
} |
OS_EXIT_CRITICAL(); |
} |
} |
#endif |
#if OS_SCHED_LOCK_EN > 0
void OSSchedUnlock (void)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
if (OSRunning == TRUE) { /* Make sure multitasking is running */
OS_ENTER_CRITICAL();
if (OSLockNesting > 0) { /* Do not decrement if already 0 */
OSLockNesting--; /* Decrement lock nesting level */
if ((OSLockNesting == 0) && (OSIntNesting == 0)) { /* See if sched. enabled and not an ISR */
OS_EXIT_CRITICAL();
OS_Sched(); /* See if a HPT is ready */
} else {
OS_EXIT_CRITICAL();
}
} else {
OS_EXIT_CRITICAL();
}
}
}
#endif
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |