Yield to other threads
#include <sys/neutrino.h> int SchedYield( void ); int SchedYield_r( void );
libc
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.
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:
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |