# OS_YieldThread

## C Specification

      #include <nitro/os.h>

      void OS_YieldThread( void );

## Arguments

None.

## Return Values

None.

## Description

Conducts thread rescheduling.

The current thread tries to transfer the CPU to another the thread with the same priority to give it an opportunity to execute.

Normally, any executable thread with a higher priority than the current thread should already be executing. Therefore, if there are no executable threads with the same priority as the current thread, calling this function will do nothing. (However, there may be situations where an executable thread with a higher priority than the current thread is not executing, if some thread operation was performed while scheduling was prohibited. )

The internal operations are as follows: Threads are managed in a list, and they are sorted in descending order from highest to lowest priority (the thread at the top of the list has the highest priority ). If there are two or more executable threads in the list, the rule is to select the thread that is highest in the list. If two or more threads have the same priority level, they are selected according to their order in the list, with the one closest to the top always chosen first. If two or more threads in the list have the same level of priority as the current thread, the `OS_YieldThread()` function places the current thread behind all the other threads of the same priority level, so they have the opportunity to execute. After the order of the threads has been changed, the `OS_RescheduleThread()` function executes.

## See Also

`OS_InitThread, OS_EnableScheduler, OS_DisableScheduler, OS_RescheduleThread`

## Revision History

06/20/2005 Initial version.

CONFIDENTIAL