#include <nitro/os.h>
u32 OS_DisableScheduler( void );
None.
The internal counter value after canceling the suppression of the scheduler operation.
When this value is larger than 0, the scheduler operation is suppressed. (It is suppressed, since a value greater than 0 is always returned.)
Suppresses the operation of the thread system scheduler. In other words, this stops rescheduling temporarily.
Even when the functions such as OS_WakeupThread
and OS_SetThreadPriority
that have the possibility of generating the rescheduling of thread are called, this prevents the rescheduling of thread.
The function that cancels the suppression of the scheduler operation of OS_DisableScheduler
is OS_EnableScheduler
. Normally, these two functions should be used as a pair.
Call OS_DisableScheduler
and OS_EnableScheduler
while the interrupts are prohibited.
The scheduler has the internal counter. That counter, which is normally set to 0, increments by one with OS_DisableScheduler
and decrements by one with OS_EnableScheduler
. In addition, if it is larger than 0, this prevents rescheduling. The return value from this function is the value after the counter has changed. Therefore, after calling this function, the value that is larger than 0 is always returned.
A set of OS_DisableScheduler
and OS_EnableScheduler
as a pair can be nested.
Example:
: (void)OS_DisableRescheduler(); : // Rescheduling prohibited (void)OS_DisableRescheduler(); : (void)OS_EnableRescheduler(); : // Rescheduling still prohibited (void)OS_EnableRescheduler(); : // Rescheduling is allowed
Caution: Depending on the situation, the program may stop because there is no thread to operate. For example, if OS_DisableScheduler
was set to prevent rescheduling and OS_ExitThread
was called, the execution right cannot be given to other threads even after completing the current thread. It requires special attention to avoid such a situation.
OS_SelectThread, OS_RescheduleThread, OS_EnableScheduler
2005/03/08 Standardized the Japanese term for "interrupt."
2005/01/21 Initial version.
CONFIDENTIAL