SchedYield(), SchedYield_r()

Yield to other threads


#include <sys/neutrino.h>

int SchedYield( void );

int SchedYield_r( void );



Use the -l c option to qcc to link against this library. This library is usually included automatically.


These kernel calls check to see if other threads at the same priority as that of the calling thread are ready to run. If so, the calling thread yields to them and places itself at the end of the READY thread queue for that priority. SchedYield() never yields to a lower-priority thread. Higher-priority threads always force a yield the instant they become ready to run. This call has no effect with respect to threads running at priorities other than the calling thread's.

The SchedYield() and SchedYield_r() functions are identical except in the way they indicate errors. See the Returns section for details.

Note: Instead of using these kernel calls directly, consider calling sched_yield().

You should avoid designing programs that contain busy wait loops. If you can't avoid them, you can use SchedYield() to reduce the scheduling latency for other threads at a given priority level. Note that a thread that calls SchedYield() in a tight loop will spend a great deal of time in the kernel, which will have a small effect on interrupt latency.

Blocking states

These calls don't block. However, if other threads are ready at the same priority, the calling thread is placed at the end of the ready queue for this priority.


The only difference between these functions is the way they indicate errors:

If an error occurs, -1 is returned and errno is set. Any other value returned indicates success.
EOK is returned on success. This function does NOT set errno. If an error occurs, any value in the Errors section may be returned.


QNX Neutrino

Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes