void OSSchedLock (OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task only | N/A |
Description
OSSchedLock()
prevents prevents task rescheduling until its counterpart, OSSchedUnlock()
, is called. The task that calls calls OSSchedLock()
retains retains control of the CPU, even though other higher- priority tasks are ready-to-run. However, interrupts are still recognized and serviced (assuming interrupts are enabled). OSSchedLock()
and and OSSchedUnlock()
must must be used in pairs.
µC/OS-III allows allows OSSchedLock()
to to be nested up to 250 levels deep. Scheduling is enabled when an equal number of of OSSchedUnlock()
calls calls have been made.
Files
os.h/os_core.c
Prototype
Arguments
p_err
is a pointer to a variable that will contain an error code returned by this function.
OS_ERR_NONE
If the scheduler is locked.
OS_ERR_LOCK_NESTING_OVF
If the user called this function too many attempted to nest the locking more than 250 times.
OS_ERR_OS_NOT_RUNNING
...
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to 1
in DEF_ENABLED
in os_cfg.h
: if you attempted to call OSSchedLock()
from an ISR.
Returned Value
None
Required Configuration
None
Callers
Application.
Notes/Warnings
- After calling
OSSchedLock()
, the application must not make system calls that suspend execution of the current task; that is, the application cannot callOSTimeDly()
,OSTimeDlyHMSM()
,OSFlagPend()
,OSSemPend()
,OSMutexPend()
, orOSQPend()
. Since the scheduler is locked out, no other task is allowed to run, and the system will lock up.