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.
Instead of using these kernel calls directly, consider calling sched_yield() .
Avoid designing programs that contain busy-wait loops using SchedYield() to timeslice. If this is unavoidable, you can use SchedYield() to reduce the system load at a given priority level. Note that a program that calls SchedYield() in a tight loop will spend a great deal of time in the kernel, which will have a small effect on scheduling interrupt latency.
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.
Last modified: 2013-12-23