Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 3.05
void OSSchedLock (OS_ERR  *p_err)

File

Called from

Code enabled by

os_core.c

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

  1. After calling OSSchedLock(), the application must not make system calls that suspend execution of the current task; that is, the application cannot call OSTimeDly(), OSTimeDlyHMSM(), OSFlagPend(), OSSemPend(), OSMutexPend(), or OSQPend(). Since the scheduler is locked out, no other task is allowed to run, and the system will lock up.

Example Usage